in reply to How to Base64 Encode an array variable??

Perl URL-encodes it

No it doesn't. LWP doesn't touch the content of your request or response.

Now I want to Base64 encode @rawdata

In general, you'd need to serialize your data in some way.

In this case, you started with serialized data. Why do you split a binary file into "lines"?

open(my $fh, '<', $datafile) or die ("Could not open file \"datafile\": $!\n"); binmode($fh); my $rawdata; { local $/; $rawdata = <$fh>; }

Note that by base64-encoding your bytes, you're making your data 25% bigger for nothing.

Replies are listed 'Best First'.
Re^2: How to Base64 Encode an array variable??
by zentara (Cardinal) on Feb 01, 2010 at 16:15 UTC
    Note that by base64-encoding your bytes, you're making your data 25% bigger for nothing.

    It does allow you to turn binary data into printable text, for storage or transfer. I like to use it to include small images in scripts as data.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
      I wasn't speaking generally, only about the case at hand. One does not print HTTP file transfers or include them in scripts.