in reply to Array Element Deletion

For the last element from an array reference you could try

$arr->[-1]

instead of finding the scalar of de-referred array reference and subtracting 1 from that.

This is something that I learned here yesterday