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

    Thank you!

    Amongst other things, this is me trying to reduce the problem to the simplest demo code and losing the plot ever so slightly!

    Reductio ad absurdum or somesuch... but no matter, I no where I am now

    Bill