in reply to regex match triggers "Use of unititialized value ..." warning

$1 and $2 are both defined when the match occurs.

That can't be as there is only one set of capturing parens. The second set of parens are a non-capturing lookahead.

This would probably do what you are trying to achieve:

s/(?<=\d),(?=\d)/|/g;

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: regex match triggers "Use of unititialized value ..." warning
by mikeraz (Friar) on Feb 22, 2011 at 13:00 UTC

    Hey future readers,
    If your Perl history has not involved look-ahead and look-behind regexes, this Q&A, especially BrowserUk's A, make for a nice learning opportunity.

    Well, nice if you consider my mis-use something that can be learned from.


    Be Appropriate && Follow Your Curiosity