in reply to Re: Parsing output with a special format -- switch and yardstick
in thread Parsing output with a special format

It is a very nice solution, thank you.
Is it possible, somehow to not to start with a reasonably big number?  $result[0] = 10 ** 6;
I don't know the 'max' id it get.
By the way, in  @result = @fields[1,0,-1]; how does it work? what is the '-1' in the end?

Replies are listed 'Best First'.
Re^3: Parsing output with a special format -- switch and yardstick
by AnomalousMonk (Archbishop) on Jun 05, 2018 at 13:13 UTC
    ... @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:  <%-{-{-{-<

Re^3: Parsing output with a special format -- switch and yardstick
by ovedpo15 (Pilgrim) on Jun 05, 2018 at 12:55 UTC
    will it be easier to find only the smallest id number after the current id number argument? so the function will return only id and not array.
    In the example above it will return only 1234. How should I implement it?