in reply to for loops and 'and'
Here's what's happening (I think). The or operator provides scalar context to the first thing it tries (1..10). As the perlop manpage points out, this is false the first time it is tried (I don't really get this...). So for takes 1..11 as its range instead of 1..10.
As for your "real life" issue with the array slice and the string, my tests show that or never gives scalar context to the second operator, and that it always does to the first. Why? I don't know.
UPDATEOkay, it seems I didn't understand .. before. From perlop:
If either operand of scalar ".." is a constant expression, that operand is implicitly compared to the $. variable, the current line number.So what happens depends on where it happens. Screwey, eh?
But don't quote me on that
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: for loops and 'and'
by pg (Canon) on Nov 30, 2003 at 16:47 UTC | |
by ysth (Canon) on Nov 30, 2003 at 20:27 UTC | |
by pg (Canon) on Nov 30, 2003 at 21:12 UTC | |
by ysth (Canon) on Nov 30, 2003 at 22:39 UTC |