I've found myself holding a beautiful data structure (parsed rss using the excellent
Universal Feed Parser) but with no way to manipulate it since I don't really know python and that's a python
module (not some handy script written in python)...
so after exploring a multitude of ways of coercing this data structure into a perl data structure i've decided it's time to stop and ask for help. so far, attempts have included:
- YAML, my first choice - but PyYAML won't dump_safe and so the output isn't useful to me (since it's not standard YAML, d'oh) .. i could subclass python's yaml module and teach it how to dump these, but i don't know python, and don't really have time to learn it properly for this project
- Python's Pickling routines - sounds like their version of Storable (pickles store well..), but Perl's unpickler doesn't work so well, 'specially for these "custom objects" ... IOW, fails for the same reason as YAML
- pyperl - some mysterious set of tools that allow you embed perl code in a python script, and access it's native data structures as well... but i can't get it to compile ... we'll not go into that in this post.
the thing that kills me is that if you just print the object using python's native printer (which sort of behaves like Data::Dumper apparently) the output looks very similar to a perl hash, but not quite. doing some regex's and then eval'ing the resultant string is .. sub-par, but so tempting at this point. before i damn myself that way,
i put to the clergy:
how have you coerced your python data structres into perl?
It's not what you look like, when you're doin' what you’re doin'.
It's what you’re doin' when you’re doin' what you look like you’re doin'!
- Charles Wright & the Watts 103rd Street Rhythm Band, Express yourself