Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   problems with "for" loop in perl (http://www.go4expert.com/forums/loop-perl-t26549/)

newbie_10 22Aug2011 21:10

problems with "for" loop in perl
 
if ($string =~ /(.*?)u(.*)/s)
{

my $pre = $1;
my $post = $2;

for my $index(0..4)
{
print "$pre$index$post\n";
push(@register_list, "$pre$index$post");
}

}

is there a way to make it print like 0,1,2,3,4 and not just 1,2,3,4??

Scripting 23Aug2011 01:26

Re: problems with "for" loop in perl
 
Try to change 0 with -1. But Im not 100% suree.

pradeep 30Aug2011 13:42

Re: problems with "for" loop in perl
 
Code:

[pradeep@dev tmp]# perl -e ' for my $i(0..4) { print "$i\n"; }'
0
1
2
3
4



All times are GMT +5.5. The time now is 17:41.