Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ah ok I think I remember now:

  my @foo = (1,2);
  $foo[1]; #2

  my $foo_r = \@foo
  $foo_r->[1]; #2

  my @bar = (1,2,$foo_r);
  $bar[2]->[1]; #2
Re the sigils, you're right, I would just add, $ is for scalar and a scalar iirc can be /either/ a value or a reference, that's why $foo_r and $foo[1] above both start with $. That's what I found unhelpful, it would have been nice to have a distinct sigil for refs (but presumably Larry was out of available symbols at that point!).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: