[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: [ID 20000128.003] Bug in magic locals vs block loops?



On Fri, Jan 28, 2000 at 06:10:28PM -0800, Larry Wall wrote:
> Fact is that almost nobody ever writes loop conditions with
> !~, and the buglette won't show up with =~ because then the pattern
> doesn't match on the last iteration, and $1 wouldn't be set anyway.

Coincidentally, I happened to stumble across this quirk earlier today while
commenting on a script on another list.  In this case, it was roughly:

until ($line =~ /regex/) {
    $line = <>;
}
if ($line =~ /regex/) {
    print $&;
}

This could have been simplified to:

until ($line =~ /regex/) {
    $line = <>;
}
print $&;

were it not for this behavior.  And no !~ in the loop conditional, either.
:)


Ronald


Follow-Ups from:
merlyn@stonehenge.com (Randal L. Schwartz)
References to:
Tim_Peters@Dragonsys.com
Larry Wall <larry@wall.org>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]