#!/usr/bin/perl --
use strict;
use warnings;
use Data::Dump qw/ dd /;
use constant +{ qw{ CAT_ID 0 NAME 1 PARENT_ID 2 } };
Main( @ARGV );
exit( 0 );
sub last_category(;+) {
(
sort {
$a->[CAT_ID]
<=>
$b->[CAT_ID]
} @{ $_[0] }
)[ -1 ]
}
sub Main {
my @cats = (
[443120, "Vegetables", 443026],
[445720, "Carrot", 443120],
[443026, "Food", undef ],
);
dd \@cats;
dd( last_category( \@cats ) );
@cats = sort { $a->[CAT_ID] <=> $b->[CAT_ID] } @cats;
dd\@cats;
}
__END__
[
[443120, "Vegetables", 443026],
[445720, "Carrot", 443120],
[443026, "Food", undef],
]
[445720, "Carrot", 443120]
[
[443026, "Food", undef],
[443120, "Vegetables", 443026],
[445720, "Carrot", 443120],
]
####
$ xsh -q xpath-max-min-11117492-correct.xsh
443120
445720
443026
443120
445720
443026
max: 445720
min: 443026
####
$ cat xpath-max-min-11117492-correct.xsh
open "xpath-max-min-11117492.xml";
ls //category_id;
ls //category_id/node();
echo max: xsh:max( //category_id );
echo min: xsh:min( //category_id );