in reply to Send/receive array through IO::Socket?
If you know, 100%, that the % sign will never appear in your data, then what you already have should be enough, shouldn't it? But yes, there are better ways to serialize your data, and YAML and Storable are two ways that work. A naive and straight-forward solution would be to use Data::Dumper and eval:
I have not fully tested this method out, and though it does work for most complex data structures that involve arrays, hashes, and references to those, i coded this to only handle arrays.sub encode { return Dumper [@_]; } sub decode { my $VAR1; my $string = shift; return eval "$string"; }
I recommend using more robust ways of serializing your data, such as Storable, YAML, or even XML. But i did feel inclined to post this code, at the very least to see if anyone can see ways to break this code. :)
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Send/receive array through IO::Socket?
by samtregar (Abbot) on Dec 01, 2005 at 22:44 UTC |