http://www.perlmonks.org?node_id=105602


in reply to Re: Re: XML::Simple isn't simple!
in thread XML::Simple isn't simple!

Ah, perlref is your friend. To see the difference, look only at the leftmost part of the variable. Simply put, in this line: print $ref{'os'}->{'Linux'}->{'score'};The first part is using a hash %ref, with the key os. (Block out the first arrow and everything that comes later and you'll see what I mean.) Since %ref is not defined at that point, it prints nothing.

On the other hand, in this line: print $ref->{os}{Linux}{score};the first part is using a scalar $ref, and is using an arrow to treat it as a reference -- specifically a hash reference.

As for leaving out the quotes, as of Perl 5.mumble, you don't need to quote strings when they're used as keys to a hash.

GIH (Glad it helped ;-)

Replies are listed 'Best First'.
Re: Re: Re: Re: XML::Simple isn't simple!
by r.joseph (Hermit) on Aug 17, 2001 at 06:10 UTC
    Again, what can I say but thank you. I understand perfectly now, and I should have caught it earlier :). Thanks again!

    r. j o s e p h
    "Violence is a last resort of the incompetent" - Salvor Hardin, Foundation by Issac Asimov