Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Autovivification in perl

by choroba (Canon)
on Jan 10, 2014 at 12:42 UTC ( #1070114=note: print w/ replies, xml ) Need Help??


in reply to Autovivification in perl

It makes it possible to write

push @{ $at_line{$string} }, $line_number;

instead of

$at_line{$string} = [] unless exists $at_line{$string}; push @{ $at_line{$string} }, $line_number;
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: Autovivification in perl
Select or Download Code
Replies are listed 'Best First'.
Re^2: Autovivification in perl
by ikegami (Pope) on Jan 10, 2014 at 20:27 UTC
    Well,
    push @{ $at_line{$string} //= [] }, $line_number;
    or even
    push @{ $at_line{$string} ||= [] }, $line_number;
    would do.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1070114]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (16)
As of 2015-07-29 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (265 votes), past polls