WC -Sx- Jones <[EMAIL PROTECTED]> wrote: : : [Becuase of a recent discussion on Postfix-users list] : Would anyone like to expand/explain what, exactly, is // : matching below:
The first iteration of the loop, // matches a zero-length string. Each subsequent time it matches the last successful match. The gotcha is if there was a successful match previous to the loop: my $string = 'string'; $string =~ /d/; while (<DATA>) { ++$idx; print "Line $idx - seen $_" if //; } Above there is no change since the first match failed. Below we get a different result. Now, all matches in the loop match the last successful match. my $string = 'string'; $string =~ /i/; while (<DATA>) { ++$idx; print "Line $idx - seen $_" if //; } If you want to be certain you are matching only zero-length strings, use /()/. while (<DATA>) { ++$idx; print "Line $idx - seen $_" if /()/; } I'm curious. What prompted the question? HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>