Think about Loose Coupling | |
PerlMonks |
How can I get the four highest valued letters in an array?by supriyoch_2008 (Monk) |
on Jun 01, 2017 at 11:22 UTC ( [id://1191833]=perlquestion: print w/replies, xml ) | Need Help?? |
supriyoch_2008 has asked for the wisdom of the Perl Monks concerning the following question: Hi Perlmonks, I am interested to place the four highest valued letters in an array in descending order from two arrays x and y. Array x represents the letters and array y corresponds to the respective numerical value of each element of x. For example, 'a' refers to 9 and 'b' to 6 and so on. I have written a script which finds out the letters in descending order i.e. a b c d for the corresponding values 9 6 5 4. But I have failed to place the letters in an array. I look forward to the suggestions of perlmonks to sort out this problem. Here goes my script:
I have got the results in cmd as follows: C:\Users\S>cd d* C:\Users\S\Desktop>y3.pl #################################### 4 highest valued letters: #################################### a b c d C:\Users\S\Desktop>Expected Results: I want the results in an array so that I can further operate on the array elements: my @array=qw/a b c d/; # in descending order of values print "\n @array\n"; Result: a b c d
Back to
Seekers of Perl Wisdom
|
|