Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 perusing the Monastery: (6)
As of 2014-08-22 08:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (150 votes), past polls