in reply to Re: Re: Writing Out Binary Files
in thread Writing Out Binary Files
Do you want to convert all the numbers into binary floating point values? First, you will need to split the lines into the numbers
while (defined($line = <IN>)) { push @data, split(' ', $line); } my $string = pack("d*", @data);
Notice in the above snippet that Perl is not C and doesn't require using array indexes for putting stuff into an array. Perl has the push operator to append to an array. In this case, it pushes the array of values that split returns. Perl can even read the entire file into an array of lines.
@data = <IN>;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Writing Out Binary Files
by Anonymous Monk on May 08, 2003 at 17:11 UTC |