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

No, the regex engine has it right. Since the capturing group didn't match, $1 is undef. If $1 contained the empty string, it would mean that the associated capturing group matched a zero-length string (not possible in your example, but in general it's possible).

I don't see a reason to change the regex though, if it does what you want. Just switch off the warning.

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

Replies are listed 'Best First'.
Re^2: Bug? Use of uninitialized value $1 in substitution iterator
by clinton (Priest) on Mar 04, 2009 at 13:00 UTC

    OK, fair enough. This same code started throwing up errors today which it wasn't throwing before - I'd refactored some other code around it - so it had me worried.

    My solution was, as you suggest, to turn of those warnings.

    thanks Moritz