[Chicago-talk] removing line from file.
Wiggins d'Anconia
wiggins at danconia.org
Wed Mar 9 12:02:51 PST 2005
Jim Thomason wrote:
>># ignore first 4 lines
>> next if 1 .. 4;
>
>
> I believe that should be:
>
> next if $. == 1 .. $. == 4;
>
> 1..4 won't work, since both 1 and 4 are true values, it never hits the 'next'.
>
> -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
More information about the Chicago-talk
mailing list