lttteam
2005-11-24 12:14:39 UTC
Hi,
I am running into an issue with Perl 5.8.4 (downloaded the source from
cpan and compiled for NetWare) while writing hex data to file.
My code snippet is:
$a_Number = 1034;
$a_HexNum = sprintf("%8X",$a_Number);
$a_Packed = pack("H*",$a_HexNum);
open($fd, "> sys:\pack.dat");
binmode ($fd);
print $fd $a_Packed;
close ($fd);
The output of this (in binary format) is 00 00 04 0D 0A instead of 00 00
04 0A.
The "additional" 0D is coming because Perl seems to be treating 0A as a
linefeed and adding a carriage return (0x0D) to it.. binmode was supposed
to prevent this, any idea what's going wrong here? I tried opening with
different modes ("bytes", "raw"), but nothing seems to be working...
The Perl binary that comes with the OS - Nw 6.5, SP2, Perl version 5.8.0 -
seems to be working all fine with the code snippet I have here...
I saw a discussion thread where others had seen the same problem, and it
appears that novel developers had fixed it. Would anybody know what/where
the fix was so that I can take appropriate source and try building Perl
again..
Please help!!!!
Thanks,
Gopa
I am running into an issue with Perl 5.8.4 (downloaded the source from
cpan and compiled for NetWare) while writing hex data to file.
My code snippet is:
$a_Number = 1034;
$a_HexNum = sprintf("%8X",$a_Number);
$a_Packed = pack("H*",$a_HexNum);
open($fd, "> sys:\pack.dat");
binmode ($fd);
print $fd $a_Packed;
close ($fd);
The output of this (in binary format) is 00 00 04 0D 0A instead of 00 00
04 0A.
The "additional" 0D is coming because Perl seems to be treating 0A as a
linefeed and adding a carriage return (0x0D) to it.. binmode was supposed
to prevent this, any idea what's going wrong here? I tried opening with
different modes ("bytes", "raw"), but nothing seems to be working...
The Perl binary that comes with the OS - Nw 6.5, SP2, Perl version 5.8.0 -
seems to be working all fine with the code snippet I have here...
I saw a discussion thread where others had seen the same problem, and it
appears that novel developers had fixed it. Would anybody know what/where
the fix was so that I can take appropriate source and try building Perl
again..
Please help!!!!
Thanks,
Gopa