Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: XML::Simple isn't simple!

by r.joseph (Hermit)
on Aug 17, 2001 at 05:40 UTC ( #105598=note: print w/ replies, xml ) Need Help??


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

Well whaddya know Joe, it works. However, I don't understand the difference between the two, and why mine fails while yours succeeds! Could someone please explain to me, in detail if you don't mind, the difference between the two statements?

And, thank you VSarkiss!

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


Comment on Re: Re: XML::Simple isn't simple!
Re: Re: Re: XML::Simple isn't simple!
by VSarkiss (Monsignor) on Aug 17, 2001 at 05:55 UTC

    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 ;-)

      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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2014-09-17 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (99 votes), past polls