in reply to Re: XML::Simple and Adding Additional Nested Elements
in thread XML::Simple and Adding Nested Elements

Thank you. That's a good idea. One last question. How would I find a specific Item? I was thinking along these lines:
if ($data{Things}{Thing}{Item} = "aValue") { ...

Replies are listed 'Best First'.
Re^3: XML::Simple and Adding Additional Nested Elements
by psini (Deacon) on May 23, 2008 at 09:23 UTC

    That code will not work because your structure is an array of reference.;/p>

    You can do if ($data[0]->{Things}->{Thing}->{Item} == "aValue")

    I strongly suggest you see Data Structures in the Q&A section of the monastery.

    Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man.

Re^3: XML::Simple and Adding Additional Nested Elements
by almut (Canon) on May 23, 2008 at 09:29 UTC
    if ($data{Things}{Thing}{Item} = "aValue") {

    That would most likely not do what you want as it assigns "aValue" to the respective hash entry... :) — remember: eq is for string comparison.

      :(

      I saw the "=" and corrected it as "=="... Who can I ask for having 10 XP removed for this? :)

      Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man.

        psini:

        Oh, I wouldn't worry about it. I'm certain that at least 10 monks around here will help you with penance for your transgression. ;^)

        ...roboticus