NAME
File::Binary - Binary file reading module
SYNOPSIS
use File::Binary;
# open an SWF file as a new File::Binary object ...
$bin = new File::Binary('test.swf') or die "Couldn't open test.swf\n";
# ... and check tos ee that it's a valid SWF file
$bin->getBytes(3) eq 'FWS' or die $bin->getFilename()." is not a valid SWF file\n";
# get bytes and words
$format = unpack("C",$bin->getBytes(1));
$width = $bin->getWord;
# get bits and signed bits
$hasloops = $bin->getBits(1);
$hasend = $bin->getSBits(2):
# find out where you are
print "File Position : " . $bin->where() . "\n";
# seek to arbitary places in the file
$bin->seekTo($bin->where + 100) or die "Couldn't seek to that position\n";
# make sure that all the bit buffers are flushed and reset
$bin->initBits;
DESCRIPTION
File::Binary is a Binary file reading module. It is currently being used to write a suite of modules for manipulating Macromedia SWF files available from http://www.twoshortplanks.com/simon/flash/ </gratuitous plug>, and as such is heavily biased towards this.
BUGS
getSBits does not handle negative numbers well.
It used to slurp all of the file into an array which made it very unsuitable for large files. This was fixed in version 0.3 by Leon Brocard. There may be problems with the filehandle returning undef for no particular reason.
AUTHOR
Simon Wistow, <simon@twoshortplanks.com>