From: Ironhide on
Hi,

This is what I am trying to achieve.

Create a copy of a file.
User inputs starting offset and end offset for the file.
For this range the perl program should calculate the md5sum
for both the original file and the copied file and compare them
both.

Any idea how to go about dealing with the offsets?
From: J�rgen Exner on
Ironhide <gourabbaksi(a)gmail.com> wrote:
>Create a copy of a file.
>User inputs starting offset and end offset for the file.
>For this range the perl program should calculate the md5sum
>for both the original file and the copied file and compare them
>both.
>
>Any idea how to go about dealing with the offsets?

All the MD5 modules I have seen accept text as input. So just read those
parts from both files and then run the MD5 algorithm on the extracted
text.

jue
From: Tad McClellan on
Ironhide <gourabbaksi(a)gmail.com> wrote:

> User inputs starting offset and end offset for the file.
> For this range the perl program should calculate the md5sum

> Any idea how to go about dealing with the offsets?


perldoc Tie::File


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
From: Steve C on
Ironhide wrote:
> Hi,
>
> This is what I am trying to achieve.
>
> Create a copy of a file.
> User inputs starting offset and end offset for the file.
> For this range the perl program should calculate the md5sum
> for both the original file and the copied file and compare them
> both.
>
> Any idea how to go about dealing with the offsets?


Digest::Perl::MD5 is a pure perl implementation. You could hack
the addfile method to add optional start and end offset arguments.
It would just add a seek to start, and only read end-start bytes
instead of to end of file. (Off-by-one error left to the astute).

If you need better performance use the addfile method for
Digest::MD5. Rather than hack C source and rebuild, it might be
easier to read from STDIN. In bash this would be:

dd if=myfile ibs=1 skip=$START count=$(( $END - $START )) | mymd5sum.pl
From: Ben Morrow on

Quoth Steve C <smallpond(a)juno.com>:
> Ironhide wrote:
> >
> > Create a copy of a file.
> > User inputs starting offset and end offset for the file.
> > For this range the perl program should calculate the md5sum
> > for both the original file and the copied file and compare them
> > both.
> >
> > Any idea how to go about dealing with the offsets?
>
> Digest::Perl::MD5 is a pure perl implementation. You could hack
> the addfile method to add optional start and end offset arguments.
> It would just add a seek to start, and only read end-start bytes
> instead of to end of file. (Off-by-one error left to the astute).
>
> If you need better performance use the addfile method for
> Digest::MD5. Rather than hack C source and rebuild, it might be
> easier to read from STDIN. In bash this would be:
>
> dd if=myfile ibs=1 skip=$START count=$(( $END - $START )) | mymd5sum.pl

That seems excessively complicated. If you *really* can't afford to read
the appropriate section of the file into memory, try PerlIO::subfile.

Ben