Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: If exists (hash)

by Khen1950fx (Canon)
on Oct 06, 2011 at 16:03 UTC ( #930012=note: print w/ replies, xml ) Need Help??


in reply to If exists (hash)

You're using $xml as a scalar element, but exists requires a hash or array element. Also, remember to declare all of your variables. You forgot to declare $image. Here's the way that I would do it:

#!/usr/bin/perl use strict; use warnings; use XML::Simple; use Data::Dumper::Concise; my %xml; my $image; my $web = 'http://my-base-url/'; if(exists $xml{'result'}{'covers'}{1}{'content'}) { print Dumper($image = "$web$xml{'result'}{'covers'}{1}{'content +'}"); } else { print Dumper($image = "$web$xml{'result'}{'covers'}"); }


Comment on Re: If exists (hash)
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2015-07-06 22:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls