Make the \d optional, not the capture:
use strict; use warnings; my $str; #$str = "6%var% after"; $str = "%var% after"; # <-- warning is triggered $str =~ s/(\d?)%var%(.*)/$1REPLACED$2/; # <-- moved the '?' print "$str\n"
By the way, I don't get the warning under Active Perl 5.6.1, but I did with perl v5.8.0 built for i386-freebsd
In reply to Re: Regex triggering uninitialised values
by ikegami
in thread Regex triggering uninitialised values
by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |