On 3/22/06, tom arnall <[EMAIL PROTECTED]> wrote:

> could you explain in detail what the stuff in parens is about, i.e.,
> '?=.*\.' ?

When the first thing inside the parentheses is a question mark, it's a
sign that the parentheses are doing something special.

     s/\.(?=.*\.)/_/gs

The perlre manpage explains that (?=...) is "a zero-width positive
look-ahead assertion." It matches if the pattern inside (that is,
between the "=" and the closing parenthesis) would match at the
current match position, but it doesn't change the match position. That
is, it "looks ahead" to see whether something would match, but the
lookahead part isn't involved in the substitution.

So, the pattern match is matching (and thus replacing) only a dot, so
long as it's eventually followed by another dot.

Does that give you what you needed? Cheers!

--Tom Phoenix
Stonehenge Perl Training

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


Reply via email to