Note that the "magic" in the two answers that you have been given already is the [-1]. Index -1 gets you the last element in an array. -2 gets the penultimate element and so on.
Also of interest is $#array which gives the index number of the last element in @array. That is (generally) different than scalar @array which returns the number of elements in @array.
In reply to Re: split string and always get last word
by GrandFather
in thread split string and always get last word
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |