in reply to undefined backreferences
I actually fiddled around with a substitution regexp the other day in this node. The regexp looked like this:
$pad =~ s/(?:z(.)(?:z.)+)|(?:.(.))/$1$2/g;
Because of the alternation, either $1, or $2 would be defined, and the other would be undefined, or uninitialized. The result was that I kept getting the same warning you're trying to avoid. My solution was to turn off the specific warning within the narrowest scope possible. This is easy, as the "use warnings" and "no warnings" pragmas can be lexically scoped. For example:
use strict; use warnings; my $pad = "whatever..."; { no warnings qw/uninitialized/; $pad =~ s/(?:z(.)(?:z.)+)|(?:.(.))/$1$2/g; } # here, all warnings are active again.
Within the curly brackets the "uninitialized" warning is silenced, but throughout the rest of the code it's still active.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: undefined backreferences
by frasco (Beadle) on Jan 26, 2009 at 08:28 UTC | |
by davido (Cardinal) on Jan 26, 2009 at 08:44 UTC |