My name seems to be littered all over the message board for replies, but now I'm asking a question! :-)
I'm playing with binary files in Perl, or rather trying to. As I'm into digital audio, I figured the first step would be to try and write a routine that read in the header from a WAVE file. So, I wrote this:-
my $wavefile = shift(@ARGV)
file in binary mode.
open FILE, "<$wavefile";
details of file.
my $chunkname = "";
my $datalength = 0;#Get
read FILE, $chunkname, 4;
read FILE, $datalength, 4;
$datalength = pack('L', $datalength);#Other
stuff would go here...#Close
print "Header: $chunkname
Length Of Data: $datalength
$chunkname ends up containing "RIFF" as it should. $datalength, the next 4 bytes, is a 4 byte unsigned long integer, and I believe I am using the correct template in the pack function. However, for some reason, $datalength comes out empty after the call to pack(). Before that function, it contains the 4 character equivalent, but it's a bit meaningless like that!
Any ideas, please?
Thanks a lot,
Count your downloads:http://www.downloadcounter.com/
And host your site:http://www.incrahost.com/
Don't say I never give you anything... ;-)