in reply to split string and always get last word
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: split string and always get last word
by AnomalousMonk (Archbishop) on Aug 14, 2021 at 16:42 UTC | |
|
Re^2: split string and always get last word
by sulfericacid (Deacon) on Mar 02, 2006 at 02:22 UTC | |
by matze (Friar) on Mar 02, 2006 at 11:40 UTC | |
|
Re^2: split string and always get last word
by linux454 (Pilgrim) on Mar 02, 2006 at 02:53 UTC | |
by GrandFather (Saint) on Mar 02, 2006 at 02:57 UTC | |
by inman (Curate) on Mar 02, 2006 at 11:56 UTC |