On 26 Nov 2005 01:16:37 -0800,
wrote:
Well your opening a file, reading a block into a buffer
then printing a few characters. I know this answer in
ansi C but I'm not sure here. Did you change the read
mode to binary after you opened it?
>Hi,
> I had trouble with a Perl parsing program not working on two different
>machines. I have now boiled it down to the minimal example.
>Basically i run the code below on 1) fedora core 3, Perl v5.8.5 and
>on 2) Linux ret hat Enterp. Perl v5.8.0.
>The code reads 4 bytes from the same file and the outputs are:
>1)
> length= 156
>0
>0
>9
>0
>
>2)
>length= 156
>0
>0
>9
>114
>
>
>
>As bytes are read i can't see how it can be related to endianess.
>Does anyone have an idea what could be wrong?
>
>Any help greatly appreciated as i am a bit out of ideas of how to
>triangulate the error further.
>
>Cheers
>Soren
>
>
>
>
>CODE:
>
> if (!open(GEF, "<".$filename)) {
> warn "Can't open file $filename: $!\n";
> return 1;
> }
>
> print "length= ".read(GEF, $pixel_hdr, 156). "\n";
>
> my $q;
> for ($q=0; $q < 4; $q++)
> {
> my $tempstring = substr($pixel_hdr, 124+$q, 1);
> print unpack("c", $tempstring);
> print "\n";
> }