vinoth.ree has asked for the wisdom of the Perl Monks concerning the following question:
In the following foreach loop I used $num variable to hold the each array elements in another foreach loop I used $_, which foreach loop will be efficient ?
my @numbers = (1,2,3,4,5); foreach my $num (@numbers){ print "$num\n"; }
my @numbers = (1,2,3,4,5); foreach (@numbers){ print "$_\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Variable usage
by ambrus (Abbot) on Mar 05, 2009 at 07:23 UTC | |
by ChemBoy (Priest) on Mar 05, 2009 at 07:34 UTC | |
by ikegami (Patriarch) on Mar 05, 2009 at 07:37 UTC | |
Re: Variable usage
by bart (Canon) on Mar 05, 2009 at 08:14 UTC | |
Re: Variable usage
by ikegami (Patriarch) on Mar 05, 2009 at 07:36 UTC |