Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Autovivification in perl

by choroba (Chancellor)
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;
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

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 drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2016-07-28 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (255 votes). Check out past polls.