in reply to Re^2: Parsing output with a special format -- switch and yardstick
in thread Parsing output with a special format
... @result = @fields[1,0,-1]; how does it work?
Please see Slices in perldata.
what is the '-1' in the end?
It's an array index. (Update: See Subscripts in perldata.) In Perl, negative indices access array elements from the end of the array:
c:\@Work\Perl\monks>perl -wMstrict -le "my @ra = qw(first second some other stuff penultimate ultimate); ;; printf qq{$_ } for @ra[ 1, 0, -2, -1 ]; " second first penultimate ultimate
Give a man a fish: <%-{-{-{-<
|
|---|