Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: map <IF> to hash with replacement

by crashtest (Curate)
on Feb 05, 2010 at 01:49 UTC ( #821487=note: print w/ replies, xml ) Need Help??


in reply to map <IF> to hash with replacement

Your immediate problem seems to be solved, but based on your question, I am guessing you are doing some sort of XML processing. If you are, I'd suggest you skip re-inventing any wheels and consider the resources already available.

The main XML parsing module on CPAN is XML::Parser. A handier interface to it is provided by XML::Simple.

PerlMonks has a tutorial on XML::Parser, although it's almost ten years old.

Edit: As I wrote this, in the back of my mind I was hoping that another monk would help out in case my recommendations were out of date. Your Mother came through - thanks!


Comment on Re: map <IF> to hash with replacement
Re^2: map <IF> to hash with replacement
by Your Mother (Canon) on Feb 05, 2010 at 02:22 UTC

    I understand this is well intentioned but I think it's bad advice. XML::Twig, XML::Rules, and XML::LibXML are probably all to be preferred over XML::Parser; I'd argue the libxml wrapper is definitely a better choice. And XML::Simple is anything but; it's a maze of special cases and their mapping parameters. It can be a very useful module but I wouldn't recommend it without knowing the problem and input at hand.

      I would use XML::Simple. It's dead easy to bring XML in as Perl structures.
      use XML::Simple qw{XMLin}; print keys %{XMLin("<root><x>1</x><y>2</y></root>")};
      This prints "xy".

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://821487]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2014-11-29 05:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls