Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Autovivification in perl

by choroba (Abbot)
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
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 avoiding work at the Monastery: (4)
As of 2014-10-02 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (41 votes), past polls