in reply to Re^6: Problem with traversing a two dimensional array (to create an arrayref use [ ] )
in thread Problem with traversing a two dimensional array

Your terminology is a bit off. The construction (split...)[2] picks out one element of the list returned by split (it does not create an anonymous array). OTOH, [split...] creates an anonymous array (initialized by the list returned by split) and returns a reference to it. Saying [split...]->[2] would create an anonymous array, then return one element of it (and then discard the anonymous array).
  • Comment on Re^7: Problem with traversing a two dimensional array (to create an arrayref use [ ] )

Replies are listed 'Best First'.
Re^8: Problem with traversing a two dimensional array (to create an arrayref use [ ] )
by Laurent_R (Canon) on Jan 16, 2014 at 23:19 UTC
    Oh, well, my terminology might be off and, although I think that I can claim to have a relatively good command of the English language, it is not my mother tongue and I may sometimes goof on some fine subtleties, but I was careful enough not to say that (split...) creates an anonymous array, but only that the thing does behave (at least in a number of respects) as if it were an anonymous array. Accessing elements with an index, manufacturing array slices, getting an element count in a scalar context, just to give a few examples, are things that you can do with an array and not with a list. But, OK, I have no desire to argue endlessly on this (especially not with an Anonymous Monk, where I don't even know if the person talking to me is always the same person), let's consider that you were right and forget it. I have no intention to argue any further on this.
      Accessing elements with an index ... you can do with an array and not with a list.

      Why do you say that? Are you assuming that "list" means "linked list"? That's not what we mean by "list" in Perl.

      I think you're right about the element count in scalar context. I seem to remember reading something like "there's no standard way of converting a list to a scalar," but I can't remember where.

      Anyway, I'm not trying to be argumentative, I'm just trying to clear up misunderstandings people might have with Perl. And I sometimes post anonymously when I'm on public wireless access points. Happy perling to you.