Can a PHP script unserialize a Storable file created with Perl?

1.4k Views Asked by At

Can a PHP script unserialize a Storable file created with Perl?

4

There are 4 best solutions below

2
On BEST ANSWER

No, but you can dump PHP-readable data from Perl with PHP::Serialization. You also might want to pick something more standard, like YAML or JSON. Pretty much any language can understand those.

2
On

As chaos points out, you asked for Storable specifically, and so switching to YAML (or JSON) may be possible, but it may not. This might work to get it into YAML (or even JSON):

$output_format = 'YAML';
popen( "perl -MStorable -M${output_format}::Syck=Dump -e 'print Dump( retrieve( q{$storable_file_path} ))'", "r" );
0
On

You could use JSON as a lingua-franca between the two languages, I suggest JSON::XS on the Perl side (with subroutines implemented in C/C++) for performances, then you can read back (in PHP) the JSON with this extension.

5
On

PHP being Turing-complete and all, the answer isn't really "no" so much as "not natively or with any well-known public module".