Johnson, Reginald (GTS) wrote:
Thanks to all that assisted in this thread. I think I am now getting
where I want to go with using hashes. One comment that I could use
clarification on is:
JR(> for ( $i=0; $i <= $number_of_elements-1; $i++ ) {
don't loop over indices, loop over the data.
JR(> $element = (split /,/, $_)[$i];
What is meant by don't loop over indices, loop over the data? Isn't the
purpose of the indice to control how many times you loop?
Perl has many tools for manipulating arrays and you rarely need to use
indexes.
Loop by index:
for my $index ( 0 .. $#array ){
my $item = $array[$index];
}
Loop by element:
for my $item ( @array ){
}
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/