T
tony.fountaine
I am relatively new to using perl and have run into a problem reading a
binary file. It seems like it only occurs when reading a short with
value of 26 or 0x001a. I decide to create a simple program to
reproduce the problem and succeded. Could someone tell me what is
wrong with the following code.
$outfile='>c:\data.txt';
$infile='c:\data.txt';
open(OUT, $outfile) or die "Could not open output file";
$b = pack("S", 26);
print OUT "$b";
close (OUT) ;
open(IN, $infile) or die "Could not open input file";
sysread (IN, $a,2) ;
$a = unpack("S", $a);
close(IN);
print "Value of a = $a";
Thanks
Tony
binary file. It seems like it only occurs when reading a short with
value of 26 or 0x001a. I decide to create a simple program to
reproduce the problem and succeded. Could someone tell me what is
wrong with the following code.
$outfile='>c:\data.txt';
$infile='c:\data.txt';
open(OUT, $outfile) or die "Could not open output file";
$b = pack("S", 26);
print OUT "$b";
close (OUT) ;
open(IN, $infile) or die "Could not open input file";
sysread (IN, $a,2) ;
$a = unpack("S", $a);
close(IN);
print "Value of a = $a";
Thanks
Tony