Rob Dixon <[EMAIL PROTECTED]> wrote:
> My apologies. There was a mistake in my code in that I was
> using the special variable $a for this loop. I should have
> written something like this:
>
> my %h;
>
> print "Matrix is as follows :- \n";
> foreach (@arr) {
> my @vals = @$_;
> print "Row = @vals\n";
> my $key = shift @vals;
> $h{$key} = [EMAIL PROTECTED];
> }
1) Why use $_ when you can have a perfectly fitting
descriptive variable name like $row?
2) If you're creating a copy of the row data, then
the shift is superfluous.
print "Matrix is as follows :- \n";
foreach my $row (@arr) {
print "Row = @$row\n";
my($key, @vals ) = @$row;
$h{$key} = [EMAIL PROTECTED];
}
Cheers,
Thomas
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/