Perl Style: Negative Array Subscripts
- To get the last element in a list or array, use
$array[$#array]. The former works on both lists and arrays, but the latter does not.
splicealso accept negative subscripts to count back from the end.
split(@array, -2); # pop twice
Remember substr is lvaluable:
substr($s, -10) =~ s/ /./g;
Copyright © 1998, Tom Christiansen All rights reserved.
Something wrong with this article? Help us out by opening an issue or pull request on GitHub