Hi John/Philip,

Thank you both for your comments -- I have to admit that this wasn't something that I thought about but it should have been. I'm sure as I progress, this would have been an annoying bug to locate...

Thank you for saving me some stress!  :-)

Ray


John W. Krahn wrote:
Philip Potter wrote:
On 8 April 2010 06:30, Raymond Wan <r....@aist.go.jp> wrote:
my $buffer = <STDIN>;
my @buffer = split //, $buffer;
for (my $i = 0; $i < length ($buffer); $i += 4) {
print unpack ('I', $buffer[$i].$buffer[$i + 1].$buffer[$i + 2].$buffer[$i +
3]), "\n";
}

Are you sure you want to read using the <> line input operator?
Consider the file (as a hexdump):
00000000 000a0000
...
Use 'read' instead (perldoc -f read) to read binary data.

You *can* use readline to read binary data.

binmode STDIN;
local $/ = \16;
my $buffer = <STDIN>;
print unpack 'I*', $buffer;

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to