New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$h{k} ||= autovivifies differently from $h{k} = #9903
Comments
From andrew@pimlott.netCreated by andrew@pimlott.netThe following script my %h; outputs key does not exist This defeats the purpose of the ||= for conditional assignment idiom. I Andrew Perl Info
|
From @leonerdOn Thu, 08 Oct 2009 12:18:26 -0700
It may be of further interest to note that the following script my %h; outputs key exists which more accurately depicts what the internals of the VM do under this -- leonerd@leonerd.org.uk |
The RT System itself - Status changed from 'new' to 'open' |
From @davidnicolhere's a workaround using a nonautovivifying subroutine argument reference: perl -wle "sub S { $_[0] ||= die};eval {S $h{k}};print exists $h{k} ? for a quick and backwards-compatible repair, you could make a sub TrueOrAssign($$){ $_[0] ||= $_[1] } to replace the identified key leak in your program. |
Migrated from rt.perl.org#69666 (status was 'open')
Searchable as RT69666$
The text was updated successfully, but these errors were encountered: