How can I write a Perl hash to file, in such a way that it can be read from Python?
For example:
#!/usr/bin/perl
my %h = (
foo => 'bar',
baz => ['a', 'b', 'c'],
raz => {
ABC => 123,
XYZ => [4, 5, 6],
}
);
dumpHash('/tmp/myhash', %h);
... and
#!/usr/bin/python
h = readHash('/tmp/myhash')
print h
# {
# 'foo': 'bar',
# 'baz': ['a', 'b', 'c'],
# 'raz': {
# 'ABC': 123,
# 'XYZ': [4, 5, 6]
# }
# }
I normally use Perl's built-in Storable
to serialize hashes. I see Python has a Storable reader, but it's not part of the standard distribution.
Is there a way to do this with standard built-ins from both languages.