oha has asked for the wisdom of the Perl Monks concerning the following question:
$x{$k} &&= $v;
I expected the previous code to modify the hash only if the key is already there (and with a true value), or leave the hash untouched otherwise.
Instead it add the key also if it's missing, but with undef value.
Am I missing something?$ perl -E 'use Data::Dumper; my %x; $x{a}&&=1; say Dumper(\%x);' $VAR1 = { 'a' => undef };
TIA
This is perl 5, version 12, subversion 4 (v5.12.4) built for x86_64-li +nux-gnu-thread-multi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: &&= vivify keys?
by Eliya (Vicar) on Apr 18, 2012 at 09:06 UTC | |
by oha (Friar) on Apr 18, 2012 at 09:10 UTC | |
by ikegami (Patriarch) on Apr 18, 2012 at 21:16 UTC | |
|
Re: &&= vivify keys?
by dada (Chaplain) on Apr 18, 2012 at 09:49 UTC | |
by ikegami (Patriarch) on Apr 18, 2012 at 21:01 UTC | |
by Eliya (Vicar) on Apr 18, 2012 at 22:03 UTC | |
by locked_user sundialsvc4 (Abbot) on Apr 18, 2012 at 11:23 UTC | |
by Your Mother (Archbishop) on Mar 30, 2018 at 22:14 UTC | |
|
Re: &&= vivify keys? (for or)
by tye (Sage) on Apr 18, 2012 at 13:15 UTC | |
|
Re: &&= vivify keys?
by Anonymous Monk on Apr 18, 2012 at 09:04 UTC | |
|
Re: &&= vivify keys?
by Anonymous Monk on Apr 18, 2012 at 09:18 UTC | |
|
Re: &&= vivify keys?
by jwkrahn (Abbot) on Apr 18, 2012 at 19:33 UTC | |
by ikegami (Patriarch) on Apr 18, 2012 at 21:21 UTC |