in reply to Re: Trouble with loops
in thread Trouble with loops
you don't need a loop
I guess the program doesn't need to loop through an array if the program author has already looked the array over and seen that the stated criterion only applies to the first element. By the same reasoning, you don't need shift:
my @array = qw( joby andy ben tom bob ); print "start\n"; for my $name ( @array ) { print "$name\n"; } print "\nmiddle\n"; print "deleted the first element because it was 'joby'\n"; @array = qw( andy ben tom bob ); print "\nend\n"; for my $name ( @array ) { print "$name\n"; }
|
|---|