Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Bug? Use of uninitialized value $1 in substitution iterator

by bellaire (Hermit)
on Mar 04, 2009 at 13:01 UTC ( #748127=note: print w/ replies, xml ) Need Help??


in reply to Bug? Use of uninitialized value $1 in substitution iterator

$1 is undefined, and any use of undef will trigger the warning. You can use the following regex if you don't want to turn the warnings off:

s{^(?:aa(bb))?.*}{defined($1)?$1:q{}}ei;
The e switch lets you use code for the replacement, so you can test whether $1 is defined before using it, and if it's not defined, use the empty string instead.


Comment on Re: Bug? Use of uninitialized value $1 in substitution iterator
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-08-31 02:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls