Hi,
When I ask for the filehandle position (tell) it is reporting the
pointer as being a few bytes further along than I expect it to be.
For instance if I do this:
#!/bin/perl
use strict;
use warnings;
my ($start,$d,$var);
my $file = 'myjpeg.jpg';
open(FH,$file) or die "Can't open $file: $!\n";
binmode(FH);
while (<FH>) {
if ($_ =~ /\xFF\xC0/) { # Start of frame header.
print "Found start of frame at $start\n";
seek(FH,$start,0);
my $read = read(FH,$var, 2);
print unpack("H*", $var), "\n";
# This should return ff C0 or at least the next 2 bytes
print "read $read characters at $start and got $var\n";
}
}
It tells me that it is reading at 7345. Yet when I open the same file
in a hex editor and search for 'ff c0' it reports the position as
7290.
Is this because it is reading the file in line by line? Setting $/;
doesn't change the output. Can anyone explain this?
TIA,
Dp.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/