in reply to How to get 2nd highest value from an array?

Hi,

A simplest way u can try...

@arr = (1..10); print sort($arr[$#arr]-1);

Regards
Franklin

Don't put off till tomorrow, what you can do today.

Replies are listed 'Best First'.
Re^2: How to get 2nd highest value from an array?
by tweetiepooh (Hermit) on Dec 14, 2005 at 15:39 UTC
    Well the code above prints value-1 of the last element not the value of the next to last element. In an array of sequential numbers the result may be the same ie element 9 contains value 9.

    So the print statement becomes

    print sort($arr[$#arr-1]);
    ?