On 1/25/2011 6:07 PM, Rob and Shawn wrote:
Hey Mike

What you have written can be fixed by changing it to

  for (my $num = 0; $num <= $#linkder; $num++) {
    print STDERR "@{$linkder[$num]}\n";
  }

or even

  for (my $num = 0; $num <= $#{$links}; $num++) {
    print STDERR "@{$links->[$num]}\n";
  }

but it is much clear and more Perlish to write

  foreach my $link (@$links) {
    print STDERR "@{$link}\n";
  }

Remember: everywhere you could put a simple variable identifier you can
put a reference. Surrounding it in braces is always valid and helps
resolve ambiguity, so @linkder is the same as @{linkder} is the same as
@{$links}. Likewise, $linkder[$num] (or $links->[$num]) is an array
reference, and can be dereferenced with @{$linkder[$num]}.

HTH,

Rob

You also might want to look into Data::Dumper to see exactly what you're
working with.

Off the top though:
map {@$_} @$arr

might be a start.

_____________________________________________



Thank you Rob and Shawn.  It worked well.
I can't claim I know fully why, but it worked.

I sure hope Perl6 gets rid of dereferencing.


Mike Flannigan



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to