in reply to Re: Preventing unintended list expansion inside hash literals.
in thread Preventing unintended list expansion inside hash literals.
Hello kcott,
I considered using scalar too, but then the comma operator returns the right-most value in the list, which doesn’t seem to be what the OP is looking for:
19:53 >perl -MData::Dump -wE "sub f { return (17, 42); } my %h = ( key +1 => scalar f() ); dd \%h;" { key1 => 42 } 19:54 >
Cheers,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Preventing unintended list expansion inside hash literals.
by kcott (Archbishop) on Jan 05, 2017 at 10:38 UTC | |
by Athanasius (Archbishop) on Jan 05, 2017 at 13:00 UTC |