in reply to Re: Writing Out Binary Files
in thread Writing Out Binary Files
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!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
#!/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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Writing Out Binary Files
by Thelonius (Priest) on May 08, 2003 at 16:28 UTC | |
by Anonymous Monk on May 08, 2003 at 16:58 UTC | |
|
Re: Re: Re: Writing Out Binary Files
by iburrell (Chaplain) on May 08, 2003 at 16:54 UTC | |
by Anonymous Monk on May 08, 2003 at 17:11 UTC |