Subject: | Warnings with replace() vmethod |
This TT2 template is generating warnings:
$ tpage
[%
SET bla = "foo";
bla.replace("(doesnotmatch)?(foo)", '$1$2');
%]
(CTRL-D)
Use of uninitialized value in subtraction (-) at
/usr/lib/perl5/Template/VMethods.pm line 221.
Use of uninitialized value in subtraction (-) at
/usr/lib/perl5/Template/VMethods.pm line 221.
Use of uninitialized value in substr at
/usr/lib/perl5/Template/VMethods.pm line 221.
The existence of a warning is somehow consistent with an equivalent
perl program:
use warnings;
my $bla = "foo";
$bla =~ s{(doesnotmatch)?(foo)}{$1$2};
__END__
Use of uninitialized value $1 in concatenation (.) or string at
ttreplaceprob2.pl line 16.
But the difference here is that a perl programmer may choose to say
"no warnings" here, or make use of the /e option and check the
defined-ness in the right-hand side. The TT2 programmer cannot cease
the warnings.
Regards,
Slaven