Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: operation inside reference

by LanX (Canon)
on May 18, 2013 at 14:21 UTC ( #1034099=note: print w/ replies, xml ) Need Help??


in reply to operation inside reference

just to add some code example to the excellent explanation by AnomalousMonk

DB<116> use warnings; $a=undef; print "< @{$a} >" Use of uninitialized value in array dereference at (eval 49)[multi_per +l5db.pl:644] line 2. < > DB<117> use warnings; $a=[]; print "< @{$a} >" < > DB<118> use warnings; $a=undef//[]; print "< @{$a} >" < > DB<120> use warnings; $a=[1..3]//[]; print "< @{$a} >" < 1 2 3 >

As you can see generating a list from an nonexistent or undef value causes a warning!

Defaulting to an empty array solves this issue.

Cheers Rolf

( addicted to the Perl Programming Language)


Comment on Re: operation inside reference
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1034099]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (10)
As of 2015-07-31 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls