Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

cease warnings in replace vmethod #9

Merged
merged 1 commit into from about 2 years ago

2 participants

Slaven Rezić Andy Wardley
Andy Wardley abw merged commit 8d97c6d into from April 19, 2012
Andy Wardley abw closed this April 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  lib/Template/VMethods.pm
@@ -220,7 +220,7 @@ sub text_replace {
220 220
             my ($chunk, $start, $end) = @_;
221 221
             $chunk =~ s{ \\(\\|\$) | \$ (\d+) }{
222 222
                 $1 ? $1
223  
-                    : ($2 > $#$start || $2 == 0) ? ''
  223
+                    : ($2 > $#$start || $2 == 0 || !defined $start->[$2]) ? ''
224 224
                     : substr($text, $start->[$2], $end->[$2] - $start->[$2]);
225 225
             }exg;
226 226
             $chunk;
8  t/vmethods/replace.t
@@ -200,4 +200,10 @@ oo\$1 bar
200 200
 -- expect --
201 201
 f!! ba!r! f!!ba!r!
202 202
 
203  
-
  203
+-- test --
  204
+-- name: no warnings --
  205
+[% text = 'foo';
  206
+   text.replace('(optional)?(foo)', '$1$2');
  207
+%]
  208
+-- expect --
  209
+foo
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.