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
In reply to Re: for loops and 'and'
by jweed
in thread for loops and 'and'
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |