in reply to get the peak values with perl

,in the array 1,2,3,4,2,3,5,6,3,2,4,1

  1. i want to get the peak values [4,6,4]

    Assuming the criteria is: "values where the values either side are lower", that's easy.

    Iterate from 1 .. $#array -1; if $array[ $_ -1 ] < $array[ $_ ] and $array[ $_ +1 ] < $array[ $_ ] print $array[ $_ ];

    See for, if & print.

  2. i also wanna get [4,5,6,4]

    By what criteria do you select the pair (5,6) for inclusion whilst excluding the pair (3,4)?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.