On Aug 29, 2012, at 3:37 PM, timothy adigun wrote: > > > If the OP decides to use C style of for loop, this is CORRECT: > > for( my $i=1; $i <= scalar (@startSite); $i++ ){ ...
Almost. That has a off-by-one error, as $i should not be equal to scalar(@startSite). I believe the following is correct: for( my $i=1; $i < scalar (@startSite); $i++ ){ ... } Since the '<' operator provides scalar context on both sides, this may be simplified to: for( my $i=1; $i < @startSite; $i++ ){ ... } > >> for my $i ( 0.. $#startSite ) { This is the same except that it starts with 0, not 1, and you cannot modify $i with any effect within the loop, as you can with the C-style for loop, which may be relevant for some applications. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/