Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: If exists (hash)

by choroba (Cardinal)
on Oct 06, 2011 at 13:55 UTC ( [id://929990]=note: print w/replies, xml ) Need Help??


in reply to If exists (hash)

If you change the original post, you should indicate it somehow. Otherwise, reactions to the previous version of your post become incomprehensible.

Replies are listed 'Best First'.
Re^2: If exists (hash)
by packetstormer (Monk) on Oct 06, 2011 at 14:40 UTC
    Sorry for the mess here.
    My basic question is how to print a hash key that will only be there in some records. I thought the "if exists" might work but it clearly doesn't.

      My basic question is how to print a hash key that will only be there in some records. I thought the "if exists" might work but it clearly doesn't.

      Um, your code fragment is incomplete, it does not demonstrate "if exist" not working

      See Access Hashes of Hashes etc. and Re^2: Unique value count in hash not working properly

      $ perl -Mstrict -e " my $foo = { 1, 1 }; exists $foo->{1}{2} " Can't use string ("1") as a HASH ref while "strict refs" in use at -e +line 1.
        Thanks for replying. I did read those threads (in fact I started one of them) but still being relatively new to perl I am having trouble. I notice the following:

        My code will retrieve XML results from a web page. The value below will always have data:

        $xml->{result}->{covers}

        Mostly it will be just a folder path. However, sometimes it could be more than one path in which case the following is returned:

        'result' => { 'covers' => {'1' => {'content' => '/mypath/nevr/9smith/' }, '2' => {'content' => '/mypath/nevr/9-dssmith/' }

        So when the XML appears I should look for $result->{covers}->{1}->{content}
        but this is where the error appears. I'm gonna read up some more and maybe I'll figure it out.
        Thanks for the replies though.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-18 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found