Skip to content

Commit

Permalink
cease warnings in replace vmethod (https://rt.cpan.org/Ticket/Display…
Browse files Browse the repository at this point in the history
  • Loading branch information
eserte committed Apr 19, 2012
1 parent fde062c commit 3fe5f0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Template/VMethods.pm
Expand Up @@ -220,7 +220,7 @@ sub text_replace {
my ($chunk, $start, $end) = @_;
$chunk =~ s{ \\(\\|\$) | \$ (\d+) }{
$1 ? $1
: ($2 > $#$start || $2 == 0) ? ''
: ($2 > $#$start || $2 == 0 || !defined $start->[$2]) ? ''
: substr($text, $start->[$2], $end->[$2] - $start->[$2]);
}exg;
$chunk;
Expand Down
8 changes: 7 additions & 1 deletion t/vmethods/replace.t
Expand Up @@ -200,4 +200,10 @@ oo\$1 bar
-- expect --
f!! ba!r! f!!ba!r!
-- test --
-- name: no warnings --
[% text = 'foo';
text.replace('(optional)?(foo)', '$1$2');
%]
-- expect --
foo

0 comments on commit 3fe5f0d

Please sign in to comment.