> You may also want to look into the pack** and unpack*** functions if you are
> going to be messing around with binary files.
>
Dear all:
I excerpt from web,
http://coding.derkeiler.com/Archive/Perl/perl.beginners/2004-05/0150.html,
and add them in my source code which looks like below:
#!/usr/bin/perl
my @data;
open INPUT, "24\_opt.YUV";
open OUT , ">" , "test.YUV";
binmode INPUT; Q1
binmode OUT ;
my $tmp_gold;
my $end_gold;
$end_gold=sysread INPUT, $tmp_gold, 32;
syswrite OUT, $tmp_gold; #Q2
#Q3
foreach my $byte (unpack "H*", $tmp_gold) {
push @data, $byte;
print "$byte";
}
print "@data\n";
foreach my $byte (pack "H*", $tmp_gold) {
syswrite EXCERPT_GOLD, $byte; #Q4
}
My question are:
Q1:
what is the differences of using
"use bytes; use open IN => ":bytes";"
and "binmode "?
Q2:
Pack seems the reverse of unpack, but the value I write into file at
Q2 and Q4 are different.
Is the template I give wrong?
Q3:
I found the foreach seems has no effect.
$byte will contain all the data in $tmp_gold which is unpack as hex string.
Q5: "local $/ = \1; #read one byte at a time"
I have search perldoc and $/ means $INPUT_RECORD_SEPARATOR, which
default is newline.
what it will be if we set it as \1?
appreciate your help,
miloody
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/