#!/usr/bin/perl -w use strict; while(<DATA>){ /^(\w+)\s+(\w+)$/; print "<$1><$2>\n"; } __DATA__ abc def xyz 6-7 123 456
Output:
<abc><def> <a><d> <123><456>
The second line of data won't match so shouldn't $1 and $2 be either undefined in that case (dynamically scoped to the end of their enclosing block or the next successful match as stated in perlre), or maybe retain their previous values. Why do they contain partial results? (same result for 5.6.1 and 5.8.0.RC2)
In reply to partial results in $1 $2 after re failure by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |