OK Here we go....
Hopefully this is exact enough....
Actually the previous post by 3dan was quite helpful....
what i want to do is convert an ascii file of format
similiar to :
126.000000 2003126 0.000000 -3.831776e-02
126.000692 2003126 0.016600 -3.084112e-02
126.001388 2003126 0.033300 7.476636e-03
126.002083 2003126 0.050000 3.644860e-02
This gets read into an array (1440 lines), then sent
to pack. It looks like the encoding (I am using uuencode)
takes place just fine, however, getting the original array
back from unpack is a different story (I get nothing).
I have provided the test code below:
I am new at this binary encode/conversion/decode business
so any help provided will be greatly appreciated!
#!/usr/bin/perl -w
use strict;
use FileHandle;
my @data; my $i=0;
print "Loading file: data.dat ......\n";
my $infile = "C:/plot/coveCH1.dat";
open(IN, "$infile");
my $line;
while (defined($line = <IN>)) {
$data[$i]=$line;
$i++;
}
print "$data[1]\n";
my $bin=pack("u", "@data");
my $OUT= new FileHandle;
open ($OUT, ">c:/plot/data.bin");
print $OUT $bin;
$OUT->close;
my @dataU=unpack("u",$bin);
print "$dataU[1]\n";
|