in reply to Regex triggering uninitialised values
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex triggering uninitialised values
by kiat (Vicar) on Nov 19, 2004 at 17:49 UTC | |
by Eimi Metamorphoumai (Deacon) on Nov 19, 2004 at 18:01 UTC | |
by kiat (Vicar) on Nov 19, 2004 at 18:06 UTC |