bichonfrise74 has asked for the wisdom of the Perl Monks concerning the following question:
If I run this, 'test_1' is not printed which means there are no data in the hash. This is what I want.#!/usr/bin/perl my %a = ( 'a' => '111' ); %a = (); print "test_1" if ( %a ); print "test_2" if ( defined( %a ) );
Then, nothing will be printed at all. Didn't I initialized the hash in both cases?use strict; my %a = (); ## This is the change. print "test_1" if ( %a ); print "test_2" if ( defined( %a ) );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test Presence of Data in Hash
by ikegami (Patriarch) on Jul 20, 2009 at 20:43 UTC | |
|
Re: Test Presence of Data in Hash
by davorg (Chancellor) on Jul 20, 2009 at 20:41 UTC | |
|
Re: Test Presence of Data in Hash
by bichonfrise74 (Vicar) on Jul 21, 2009 at 02:04 UTC | |
|
Re: Test Presence of Data in Hash
by poolpi (Hermit) on Jul 21, 2009 at 12:08 UTC |