Hi,
On 10/01/2011 03:39 PM, Klāvs Priedītis wrote:
> I have a question about binary files. How can I read binary files? I need to
> do folowing things: read numbers of different widths, strings.
The read() method in IO allows you to read binary data. The result is a
Buf object.
Example:
my $file = open('MyFile');
# read 10 bytes:
my $buf = $file.read(10);
$file.close;
You can write a buffer to another file handle with $fh.write($buf), and
decode them to a string via the $buf.decode($encoding) method.
Hope that helped,
Moritz