NAME

Python::Serialise::Pickle - a file for reading and writing pickled Python files

SYNOPSIS

use Python::Serialise::Pickle;

my $pr = Python::Serialise::Pickle->new("file/for/reading");
while (my $data = $pr->load()) {
      print Dumper $data;
}

my $pw = Python::Serialise::Pickle->new(">file/for/writing");

$pw->dump(['a' 'list']);
$pw->dump("a string");
$pw->dump(42);
$pw->dump({'a'=>'hash'});

$pw->close();  

DESCRIPTION

Pickling is a method of serialising files in Python (another method, Marshalling, is also available).

This module is an attempt to write a pure Perl implementation of the algorithm.

METHODS

new <filename>

Open a file for reading or writing. Can take any arguments that IO::File can.

load

Returns the next data structure from the pickle file or undef.

dump <data structure>

Takes a ref to an array or a hash or a number or string and pickles it.

Structures may be nested.

close

Closes the current file.

BUGS

Almost certainly lots and lots.

Serialised objects

At the moment we don't deal with serialised objects very well. Should probably just take or return a Python::Serialise::Pickle::Object object.

The 'None' object

Similar to Perl's undef but an object. At the moment we deal with it badly because if we returned undef then that would signify the end of the Pickle file.

Should probably be returned as a special object or something.

Longs

There's no testing for longs

Unicode

Ditto

Some nested dictionaries

Dictionaries are the Python equivalent of hashes. This module can deal with most nested dictionaries but, for some reason, this one :

a={'a':['two',{'goof':'foo', 'a':[1,2,3]}]}

causes it to fail.

Chnaging it slightly starts it working again.

Bad reading of specs

This is entirely my fault

ALTERNATIVES

You could always dump the data structure out as YAML in Python and then read it back in with YAML in Perl.

AUTHOR

Simon Wistow <simon@thegestalt.org>

COPYRIGHT

(c) 2003 Simon Wistow

Distributed under the same terms as Perl itself.

This software is under no warranty and will probably ruin your life, kill your friends, burn your house and bring about the apocalypse.

SEE ALSO

http://www.python.org, YAML, IO::File and the RESOURCES file in this distribution.