in reply to Re^4: Why does 'print shift sort @array' not work?
in thread Why does 'print shift sort @array' not work?

Aren't the following functionally equivalent, i.e. Sort, make an array and a reference to it, dereference it, get the [first] item?

print [sort @array]->[0]; print @{[sort @array]}[0];

Replies are listed 'Best First'.
Re^6: Why does 'print shift sort @array' not work?
by JavaFan (Canon) on Feb 26, 2009 at 21:36 UTC
    Aren't the following functionally equivalent,
    Technically, no. [sort @array]->[0]; does return a single element. @{[sort @array]}[0]; however is a slice with one element. I would have expected it to warn - just as @array[0] will warn. The PC way to write it is:
    print ${[sort @array]}[0];