in reply to Re: -w in production environment
in thread -w in production environment
If you used defined $USER{coffee} as a check it will actually autovivify (automatically create) the coffee key as it does when you do your current test.
That's not true:
use warnings; use strict; my %c = ( hey=>'Joe', where=>'you goin\'', with=>'that gun in your hand'); if (defined $c{Hendrix}) { print "Jimi is alive and well\n"; } foreach ( sort keys %c ) { print "Key : $_ => $c{$_}\n"; }
This does not print "Hendrix" and yield up a warning on the loop that goes through the keys (Perl 5.6.1, Win32).
Of course defined $hash{key} and exists $hash{key} do test for different things:
$hash{key} = undef; #defined $hash{key} false, exists $hash{key} true
perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
|
---|