in reply to Re: Re: Writing Out Binary Files
in thread Writing Out Binary Files

What format of binary file do you want to convert it to? Right now, your code uuencodes the file. I would not call that a binary format and there is no point in encoding the ASCII file that you have. Also, the unpack won't product an array; it will put the original file in the first element of @dataU, $dataU[0].

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
    Excellent! We are getting even closer!
    Unfortunately knowing very little about binary
    formats(being a novice at all of this),
    I would say lets go for the most efficient and
    compact binary format; so I will defer to your wisdom
    in that area.
    Again I appreciate all the help!