in reply to Re: Reading binary file byte by byte
in thread Reading binary file byte by byte
$/ is more flexible than you think.
{ open(my $FILE, "file.binary") or die $!; binmode($FILE); local $/ = \1; while ( my $byte = <$FILE> ) { ... } close $FILE; }
But messing with global variables is messy. What if "..." calls a function that reads from a file? Just use read.
{ open(my $FILE, "file.binary") or die $!; binmode($FILE); while (read($FILE, my $byte, 1)) { ... } close $FILE; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Reading binary file byte by byte
by anonymized user 468275 (Curate) on Dec 23, 2010 at 13:26 UTC | |
by ikegami (Patriarch) on Dec 23, 2010 at 16:03 UTC |