On Mon, 2008-10-06 at 22:35 +0900, Raymond Wan wrote: > Try: > > if (defined $hash{$key}) { > ... >
Defined is not the same as exists. #!/usr/bin/perl use strict; use warnings; my %data = ( b => undef, c => 1, ); for my $key ( qw( a b c ) ){ print "\$key = $key\n"; if( exists $data{$key} ){ print "\t\$data{$key} exists\n"; if( defined $data{$key} ){ print "\t\$data{$key} defined\n"; print "\t\$data{$key} = $data{$key}\n"; }else{ print "\t\$data{$key} not defined\n"; } }else{ print "\t\$data{$key} not exists\n"; } print "\n"; } __END__ -- Just my 0.00000002 million dollars worth, Shawn Linux is obsolete. -- Andrew Tanenbaum -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/