Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: partial results in $1 $2 after re failure
by blakem (Monsignor) on Jun 30, 2002 at 09:01 UTC | |
|
Re: partial results in $1 $2 after re failure
by Aristotle (Chancellor) on Jun 30, 2002 at 11:05 UTC | |
|
Re: partial results in $1 $2 after re failure
by Zaxo (Archbishop) on Jun 30, 2002 at 08:33 UTC | |
by Anonymous Monk on Jun 30, 2002 at 08:39 UTC | |
|
Re: partial results in $1 $2 after re failure
by Anonymous Monk on Jul 01, 2002 at 03:38 UTC | |
|
Re: partial results in $1 $2 after re failure
by ides (Deacon) on Jun 30, 2002 at 15:55 UTC | |
by Aristotle (Chancellor) on Jun 30, 2002 at 16:15 UTC | |
|
Re: partial results in $1 $2 after re failure
by caedes (Pilgrim) on Jun 30, 2002 at 08:52 UTC |