It's not too difficult to implement, but I'd prefer code reuse if possible.
my @arr = (2,3,4,5,5,5,4,4,3,1,1,2,3,0,2,4);
my $ret = {MAXIMA=>[{INDEX=>3, VAL=>5},{INDEX=>4, VAL=>5},{INDEX=>5, VAL=>5}],
MINIMA=>[{INDEX=>9, VAL=>1},{INDEX=>10, VAL=>1},{INDEX=>13, VAL=>0}]}
So, do you know of any module that implements something similar?