App-Jawk

 view release on metacpan or  search on metacpan

bin/jawk  view on Meta::CPAN

#  where $a and $b are indexes as specified by user.
#  Converts $a and $b to positive versions, and 
#  returns all the possible ints from $a to $b, inclusive
#  handles descending lists, unlike perl's '..'  :)
sub get_range {
    my ($a, $b, $numparts) = @_;
    $a = _restrict_to_possible( _converted_version($a, $numparts), $numparts);
    $b = _restrict_to_possible( _converted_version($b, $numparts), $numparts);
    if ( $a <= $b ) { return ($a..$b); }
    return (reverse($b..$a));    # they asked for a list in reverse. make it ascending, and reverse it.
                                 # or as Missy Elliott would say - flip it and reverse it.
}

############################################
# $num = _converted_version( $num, $numparts ) 
# returns the int $numparts converted to be as if it were sane and 1-based.
# returns 0 if there arent as many columns are requested 
# (IE, there are seven columns and you ask for the eighth).
sub _converted_version {
    my ($num, $numparts) = @_;
    if ($num < 0) {



( run in 0.985 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )