[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Storable in ASCII or XML?



On Thu, Sep 21, 2000 at 11:13:23PM +0200, Bart Lateur wrote:
> On Thu, 21 Sep 2000 13:04:47 -0700, Andrew O. Mellinger wrote:
> 
> 
> >>Data::Dumper?
> 
> >   I think that is what I'll end up using.
> 
> Be extremely careful. I've just tested it on my PC (the power supply on
> my Mac blew up today...), and this module does NOT convert arbitrary
> bytes into readbale ASCII. Not at all: all data simply pass through,
> raw!
> 
> 	$_ = pack 'C*', 0 .. 255;   # string of all possible bytes
> 	use Data::Dumper;
> 	print Dumper $_;

Fortunately, Data::Dumper can be configured to produce safe output in that
case:

perldoc Data::Dumper

       $Data::Dumper::Useqq  or  $OBJ->Useqq([NEWVAL])
           When set, enables the use of double quotes for
           representing string values.  Whitespace other than
           space will be represented as [\n\t\r], "unsafe"
           characters will be backslashed, and unprintable
           characters will be output as quoted octal integers.
 
           Since setting this variable imposes a performance
           penalty, the default is 0.  The Dumpxs() method does
           not honor this flag yet.



> You can use one of those mail/MIME modules to do base64
> encoding/decoding. By contrast, UU encoding/decoding is built into Perl.
> 
> 	$_ = pack 'C*', 0 .. 255;
> 	$uue = pack 'u*', $_;
> 	print $uue;
> 
> Look ma, Ascii only.

And there's nothing I enjoy more than editing uuencoded data.


> To decode it:
> 
> 	$raw = unpack 'u*', $uue;

Now, you just need to write a framework to serialize entire data
structures.  ;)


Ronald

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org