Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Use of uninitialized value in pattern match (m//)

by tobyink (Abbot)
on May 23, 2012 at 22:38 UTC ( #972120=note: print w/ replies, xml ) Need Help??


in reply to Use of uninitialized value in pattern match (m//)

It's the elsif condition that's triggering it. (The line numbers reported in Perl's error messages... well, there is a logic to them, but it can seem impenetrable at times. In multi-line constructs the line number reported is sometimes several lines away from where a human being would judge the error to have occurred.)

When you use a pattern match (like /^\s*$/) you need to tell it what variable to test. e.g.:

$str =~ /^\s*$/

If you do not tell it what variable to test, then Perl will test the special variable called $_. In your case, $_ appears to be undefined. Hence the message.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re: Use of uninitialized value in pattern match (m//)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (11)
As of 2015-07-28 09:21 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 (254 votes), past polls