D
David Frauzel
Quick (or maybe not) question.
What is the difference between an anonymous array, an array, and a list?
For instance, here I have a list:
print +('foo', 'bar')[0];
And here I have an array constructed using a list:
@foo = ('foo', 'bar');
Given the flexibility of those two options, when (or why) must I use an
anonymous array? (Or is the answer, "only when you need to construct a
reference to one".)
My hunch is that it has to do with THING-of-THING structures (perldsc),
since,
@foo = ('foo', ('bar', 'baz'));
just created a single flat array with 3 elements. But, then, we're back to
references. So are references really the only use for anonymous
constructors at all...?
What is the difference between an anonymous array, an array, and a list?
For instance, here I have a list:
print +('foo', 'bar')[0];
And here I have an array constructed using a list:
@foo = ('foo', 'bar');
Given the flexibility of those two options, when (or why) must I use an
anonymous array? (Or is the answer, "only when you need to construct a
reference to one".)
My hunch is that it has to do with THING-of-THING structures (perldsc),
since,
@foo = ('foo', ('bar', 'baz'));
just created a single flat array with 3 elements. But, then, we're back to
references. So are references really the only use for anonymous
constructors at all...?