in reply to Re^2: regex & variable substitution
in thread regex & variable substitution
See? The hash stays emtpy.#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %h; print $h{key} ? $h{key} : "nokey"; print "\n", Dumper (\%h);
#!/usr/bin/perl use strict; use warnings; my %h = ( a => "", b => undef, c => "true"); for ( qw(a b c d) ) { print "key: $_ is " . ($h{$_} ? "" : "not ") . "true\n"; print "key: $_ is " . (defined $h{$_} ? "" : "not ") . "defined\n" +; print "key: $_ is " . (exists $h{$_} ? "" : "not ") . "existing\n +"; } #key: a is not true #key: a is defined #key: a is existing #key: b is not true #key: b is not defined #key: b is existing #key: c is true #key: c is defined #key: c is existing #key: d is not true #key: d is not defined #key: d is not existing
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: regex & variable substitution
by kiz (Monk) on Jul 11, 2005 at 11:22 UTC |