Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by ikegami (Pope)
on Mar 04, 2009 at 15:28 UTC ( #748196=note: print w/ replies, xml ) Need Help??


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

Perl distinguishes between a capture that wasn't encountered in the match and a capture that matched zero characters.

use Data::Dumper qw( Dumper ); '' =~ / ^ ( (?: ( bb ) # $2 )? ) # $1 $ /x; local $Data::Dumper::Useqq = 1; local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 0; print('$1 = ', Dumper($1), "\n"); print('$2 = ', Dumper($2), "\n");
$1 = "" $2 = undef


Comment on Re: Bug? Use of uninitialized value $1 in substitution iterator
Select or Download Code
Replies are listed 'Best First'.
Re^2: Bug? Use of uninitialized value $1 in substitution iterator
by clinton (Priest) on Mar 04, 2009 at 18:29 UTC
    nicely explained

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2015-07-31 03:23 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