Km wrote:
> 
> Hi all,

Hello,

> when i use  range operator in foreach loop it increases the
> elements in the list by one.
> for eg :
> foreach(1..10)
> {
> print;
> }
> #prints  1,2,3,4,5,6,7,8,9,10
> 
> but if i need to set a hop for each number how do i get it ?
> something like stride functionality  so that it will print 1,4,7,10
> something like
> 
> for(1..10 ,jump 3)
> {
> print;
> }
> 
> kindly  enlighten ,

You have to use a C style for loop like this:

for ( local $_ = 1; $_ <= 10; $_ += 3 ) {
    print;
    }



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to