http://qs1969.pair.com?node_id=90291


in reply to Pasring XML into a simple hash

I have a "XML like" file <...>

If you don't want to write a custom parser from scratch or within the framework something like Parse::RecDescent provides, you'll need to convert your file into valid XML before you could use XML::Parser or XML::Simple.

But if you do, doing what you need is a cinch ...

use XML::Simple; my $xml = XMLin(<<__XML__); <posts> <post> <jobnumber>1234</jobnumber> <location>Somecity, NJ</location> </post> <post> <jobnumber>87922</jobnumber> <location>Othercity, AK</location> </post> </posts> __XML__ foreach my $post ( @{ $xml->{'post'} } ) { print "City: $post->{'location'}\n"; }

    --k.