in reply to How to Base64 Encode an array variable??
I don't get it. Why would you want to read the file to an array (one line in each element) instead of to a single string? Just slurp the whole thing to a single string and base64-encode it that way, then when you decode it, split it to lines with split /^/.
If, however, you wanted to encode data other than a simple string, you could first serialize it with one of those modules like Storable. In the particular case of storing just an array of strings, you can get away with encoding it like $str = pack "(J/A)*", @data; and decoding with @data = unpack "(J/A)*", $str;
|
|---|