> That happens because the match variables ($1, $2, ...) are only changed
> when a regular expression matches; otherwise, they are left alone.
> 
> In the first case, "$2 !~ /domain\.com/" succeeds but does not capture
> anything, so the numbered match variables are unset.
> 
> Your situation reinforces the rule that you should always test if the
> match succeeded before you attempt to use the match variables:

Very good point. I can see how in situations without a check it could
lead to very nasty (and possibly subtle) results much farther down the
chain that could take much time to track down (and create a path of
destruction until it is tracked down).

Thanks,

Steve

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


Reply via email to