kalyanrajsista has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
I'm confused of how to use the references in conditional statements like
#!/usr/bin/perl use strict; my $hash_ref = &getHashRef(); # Check if hash reference has really values in it.... if ( $hash_ref ) { .....# do something }
I want to do the processing only if there is data inside the $hash_ref. eventhough there is no data inside the hashref, it is going into the loop, which it should not be.
I'm trying the following ways. ..
# Which one is correct ..... if ( %$hash_ref ) { ...... } # OR if ( $hash_ref ) { ........ }
Also please provide me check for existence of values inside Array references.....
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Check for existance & definedness for Hash and Array references
by ikegami (Patriarch) on Sep 17, 2010 at 07:18 UTC | |
Re: Check for existance & definedness for Hash and Array references
by moritz (Cardinal) on Sep 17, 2010 at 08:01 UTC | |
Re: Check for existance & definedness for Hash and Array references
by planetscape (Chancellor) on Sep 17, 2010 at 08:26 UTC | |
Re: Check for existance & definedness for Hash and Array references
by BrowserUk (Patriarch) on Sep 17, 2010 at 06:43 UTC | |
Re: Check for existance & definedness for Hash and Array references
by TomDLux (Vicar) on Sep 17, 2010 at 16:12 UTC |
Back to
Seekers of Perl Wisdom