http://www.perlmonks.org?node_id=973301

ShiningPerl has asked for the wisdom of the Perl Monks concerning the following question:

I am studying video and other kind of files that deals with packed data. I want to break down a flv file into its byte and printing on the screen but I face alot of difficulties. My desired output to print 0b11110000 as 0xF0 but all I got was 0. Is there something wrong with the print format?

#! /usr/bin/perl $data_file="1.flv"; open (FILE, $data_file) or die ("Could not open file!"); my $len=0; while($len!=7){ read (FILE, $buffer, 1); print "Char Format: "; print "$buffer "; print "Hex Format: "; printf ("%lX ", $buffer); print " Test Print Format"; $test=255; print " ".$test." "; printf ("%lX", $test); print "\n"; $len++; } print "\n=====End of Script====="; close(FILE);