in reply to Re: Range Operators Question
in thread Range Operators Question
Still a bit confused though. After re-reading, I tried a few more examples. The goal of each is to print the numbers 5,6,7,8,9,10, one to a line.
Maybe I am misunderstanding how to use the operator is scalar context. The examples in the docs don't really help. Of all the examples listed, I thought the first was going to work. I'm really not understanding why it didn't.@arr = (1 .. 20); foreach $i ( 0 .. $#arr ) { if ( $i == (5 .. 10) ) { print "$i\n"; } } # output was "0\n" @arr = (1 .. 20); foreach $i ( 0 .. $#arr ) { if ( $i == 5 .. 10 ) { print "$i\n"; } } # output was 5-19, one integer to a line @arr = (1 .. 20); foreach $i ( 0 .. $#arr ) { if ( $i = (5 .. 10) ) { print "$i\n"; } } # no output - '$i = (5 .. 10)' never evaluated true
Thanks for your help to this point.
Amel - f.k.a. - kel
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Range Operators Question
by Dominus (Parson) on Jul 19, 2001 at 01:34 UTC | |
|
Re: Re: Re: Range Operators Question
by chipmunk (Parson) on Jul 19, 2001 at 01:54 UTC | |
by dsb (Chaplain) on Jul 19, 2001 at 02:16 UTC | |
by buckaduck (Chaplain) on Jul 19, 2001 at 02:38 UTC | |
by Hofmator (Curate) on Jul 19, 2001 at 15:11 UTC |