Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: map 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!

Replies are listed 'Best First'.
Re^2: map <IF> to hash with replacement
by Your Mother (Chancellor) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://821487]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2017-10-21 16:45 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (270 votes). Check out past polls.