Friday, January 11, 2013
11:00 PM

Perl Script - Reading / Writing Binary files

A binary file is a computer file that is not a text file; it may contain any type of data, encoded in binary form for computer storage and processing purposes.

If you want to open a file and read its content in binary mode, you should use the following functions:
 * open() to open the file to a file handle.
 * binmode() to set the file handle to binary mode.
 * read() to read data from the file handle.
 * close() to close the file handle.

Below sample Perl script demonstrate the usage of reading / writing the binary files using binary mode.

Source: binary.pl
#!/usr/bin/perl

$buffer = "";
$infile = "binary.dat";
$outfile = "binary_copy.dat";
Continue Reading...

0 comments:

Post a Comment