in reply to Re^2: regex & variable substitution
in thread regex & variable substitution

No, the key will only autivify when you assign a value to it.

Prove:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %h; print $h{key} ? $h{key} : "nokey"; print "\n", Dumper (\%h);
See? The hash stays emtpy.

Update: exists, defined and the check for truth do different things. Consider:
#!/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


holli, /regexed monk/

Replies are listed 'Best First'.
Re^4: regex & variable substitution
by kiz (Monk) on Jul 11, 2005 at 11:22 UTC
    That update is really very interesting, and very helpful! Thanks for posting it...


    -- Ian Stuart
    A man depriving some poor village, somewhere, of a first-class idiot.