Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Why will referencing an undefined value as array reference create a real array

by jeffa (Bishop)
on Jun 18, 2014 at 18:54 UTC ( #1090334=note: print w/replies, xml ) Need Help??


in reply to Why will referencing an undefined value as array reference create a real array

That's a feature called auto-vivification. Consider the following alternative:

print "this won't be printed\n" if (scalar @{$test} and scalar @{$test +}[0]);


jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: Why will referencing an undefined value as array reference create a real array
by mfort (Initiate) on Jul 28, 2014 at 15:46 UTC
    Thanks for pointing me to the Auto Vivification. I swear I learn something new every day with perl and I've been using it for decades now.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1090334]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2016-12-04 13:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (65 votes). Check out past polls.