in reply to What's happening to my $1?
In your second set of data, the "Xyz" causes the engine to start matching with the "X", but the rest of the string causes the match to fail, and thus the last read match is $1, i.e. "FOO". However, since the matching engine started a new match, the number of matched characters was reset, so that essentially there is only one valid character reported; hence, what's available in $1 is "F".
Personally, I wouldn't rely on what is not matched in $1, but would rather re-evaluate the string should the initial match fail.
YMMV. TMTOWTDI.
|