in reply to array slice?
Hello zeltus,
I think you have already answered your own main question. But your preferred syntax:
my $v3 = (@tarray)[0];
looks a little odd. At the least, it’s unnecessarily complex: it says, “Take the elements of @tarray; treat them as a list; and return the first element of that list.” More straightforward to cut out the middle step and just say:
my $v3 = $tarray[0];
If you do need a slice, an array slice is also more straightforward here than a list slice:
my ($v4, $v5) = @tarray[0, 2];
See the FAQs:
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: array slice?
by zeltus (Beadle) on Feb 03, 2014 at 12:29 UTC |