Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by jeffa (Chancellor)
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)


Comment on Re: Why will referencing an undefined value as array reference create a real array
Select or Download Code
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-12-20 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls