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);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Printing byte as 2 Hex characters
by Eliya (Vicar) on May 30, 2012 at 15:12 UTC | |
by ShiningPerl (Novice) on May 30, 2012 at 16:02 UTC | |
Re: Printing byte as 2 Hex characters
by ikegami (Patriarch) on May 30, 2012 at 15:38 UTC | |
by ShiningPerl (Novice) on May 30, 2012 at 16:01 UTC | |
by KevinZwack (Chaplain) on May 31, 2012 at 01:21 UTC | |
by Anonymous Monk on Aug 29, 2013 at 11:31 UTC | |
Re: Printing byte as 2 Hex characters
by SuicideJunkie (Vicar) on May 30, 2012 at 14:59 UTC | |
Re: Printing byte as 2 Hex characters
by toolic (Bishop) on May 30, 2012 at 14:51 UTC | |
by ShiningPerl (Novice) on May 30, 2012 at 15:17 UTC |