Can a PHP script unserialize a Storable file created with Perl?
+11
A:
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.
jrockway
2009-02-20 12:58:30
Well, you could do it if you rewrote Storable as a PHP library, couldn't you? :)
brian d foy
2009-02-20 19:13:54
That's what I'm sayin'.
chaos
2009-02-20 19:15:47
Good luck mapping Storable's concepts onto PHP (like blessed references).
jrockway
2009-02-20 19:35:43
+3
A:
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.
tunnuz
2009-02-20 13:08:56
+4
A:
PHP being Turing-complete and all, the answer isn't really "no" so much as "not natively or with any well-known public module".
chaos
2009-02-20 14:39:59
Um... no. Read the question. YAML is a solution for transferring serialized data between PHP and Perl; it is not a solution for *reading serialized data from Perl's Storable module into PHP*.
chaos
2009-02-20 17:13:15
Okay, you weren't being helpful with the early kick-out, then. BTW, thanks for all the downvotes with posts that each one contains about 3-times more helpful detail than your early kick-out.)
Axeman
2009-02-20 17:36:47
This is faintly ridiculous, since it's right there in front of you that I wrote my answer an hour after the other two. But I guess you've already demonstrated reading comprehension issues. I wrote what I wrote because the accepted answer's "no" isn't really true.
chaos
2009-02-20 18:45:23
Early kick-out="Test. No? -> Done." Like a flowchart. Actually, my reading comprehension is fine--when I reread a source. By the time I read down the page, I had forgotten the actual context. You helped me realize that the question--as asked--hadn't been answered.
Axeman
2009-02-20 19:06:47
Ah, I see. Well, glad to be of service, then. I guess it all worked out in the end.
chaos
2009-02-20 19:15:12
+4
A:
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" );
Axeman
2009-02-20 18:42:23
If you're going to exec Perl for every request, why would you be using PHP to begin with?
jrockway
2009-02-20 19:37:44
Jon (rockway), who said anything about exec-ing it every request? You could substitute -MPHP::Serialization=serialize and print serialize( retrieve( ... )), you can fwrite that string to a file or but you'd still have to fread it, no matter what.
Axeman
2009-02-20 23:31:14