I have a function which prints array:

sub print_array {
  my $array_ref = shift;
  for(@$array_ref){
     print "$_\n";
  }
}

And I have a big array, for example named @array.
I want to print @array elements from N to N+100 using this function, but 
don't want to use second array (they are can be very big). After print I 
don't need @array anymore.

I do this:
$#array = $N+100;
print_array($array[$N]);

But I got error: [Not an ARRAY reference at ... ]
Is ARRAY reference in perl not the reference to the first element of ARRAY ?
Or is the better way to solve this problem?


Please note that $array[$N] is a scalar...
Also you are expecting an array reference in your sub but not calling with a
reference...

Here is another way...

perl -e '@a=(1 .. 500); $from=0; $cnt= 5;&print_array([EMAIL PROTECTED],$from, 
$from +
$cnt);sub print_array{ ($list,$from, $to)[EMAIL PROTECTED]; print $$list[$from 
- 1], "\n"
while (++$from  <= $to) ;}'

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to