From: Monty <[EMAIL PROTECTED]>
> Thanks for all the replies, both in this group and in separate e-
> mails.
> 
> Things have been cleared up.  My major misunderstanding was in the
> fact that $1, $2, etc. can exist outside the RegEx.  I previously
> thought they had to be confined to the expression itself.  Through
> some experimenting I find they no longer exist once the block defined
> by the 'while' statement is complete.  I presume they'll get redefined
> with another RegEx, but I've yet to experiment on that.

The assignment to $1 and friends is local()ized to the current block:

"abc" =~ /.(.)./;
print "top level \$1=$1\n";
{
 "123" =~ /.(.)./;
 print "in block \$1=$1\n";
}
print "top level again \$1=$1\n";

once you leave the block in which the match occurred, the $1, $2, ... 
gets reassigned to whatever value it had before the block.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to