Hello,
I have an array and I would like to pass it to a subroutine:
&printlist([EMAIL PROTECTED]);
sub printlist
{
my $array_ref = (shift);
my $max;
my $maxnew = @{$array_ref};
for(my $i=0;$i < $maxnew; $i++){
print "\t\t\t\t\t";
if ( ($maxnew - $i) >= 10 ) {
$max = 10;
} else {
$max = $maxnew - $i;
}
for(my $n=0; $n <= $max; $n++) {
print "${$array_ref}[$i]\t";
$n++;
$i++;
}
print "\n";
}
}
I know the above works I just want to make sure I understand why,
I am passing the reference of an to the subroutine, which using (shift)
assigns the first scaler to my scaler array_ref. So now array_ref scaler
is equal to the passed scaler allowing me to use array_ref as a
reference.
Correct ?
Michael
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>