[Chicago-talk] removing line from file.

Jim Thomason thomasoniii at gmail.com
Wed Mar 9 12:07:31 PST 2005


.. is a different operator in a scalar context. In a scalar context,
it returns false until the first item returns true. Then it continues
to return true until the second operator returns true, after which it
returns false again.

I just hadn't realized that 1..4 seems to be a shortcut for $. == 1 .. $. == 4.

In normal situations (I assume when $. isn't around and being
twiddled), 1..4 is a no-op. 1 evaluates to true, then 4 immediately
evalutes to true, so nothing happens, and hence the next is never hit.

-Jim.....

> This is very odd. Your catch seems ok, but the reasoning seems odd.
> C<1..4> is a range, 1 and 4 specifically never enter the picture. And
> regardless the next would *always* get hit rather than 'never' because
> they *are* true. In this case does the 'if' get a list (1,2,3,4), or 4
> (meaning the number in the list) or 4 (the last entry in the range)?? Or
> does it really work where Perl does some magic not looping over the
> range except at each iteration of the outer 'while' (which seems
> impossible)?  Not to mention the whole binding order of .. and ==, which
> wouldn't that turn the above into:  C<if $. == (1 .. $.) == 4;>, or do I
> have my highest/lowest backwards again?
> 
> Of course, we could just opt for the less silly,
> 
> next if $. < 5;
> 
> :)
> 
> http://danconia.org
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>


More information about the Chicago-talk mailing list