Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: How to convert array key values into percentages

by ww (Archbishop)
on Jan 26, 2014 at 21:01 UTC ( #1072149=note: print w/replies, xml ) Need Help??

in reply to How to convert array key values into percentages

As AnonyMonk notes, you've left us guessing about the nature of the rule(s) by which you are planning to derive your various products, namely:
percentage of "@sorted_array[0]" is 1%. result will be: @final_array[0]=1

Whatever your method is, it eludes me (and given the lack of answers on a day with few new question, possibly is a mystery to others as well) especially since there's no obvious (again, 'to me') common path for transforming

  • "@sorted_array[0], -150," to 1%
  • "@sorted_array[3], 0," to 75%.

And then there is the trailing @final_array[5]=75 on line 7: Whence came that inexplicable entry? Is it a mere typo or cut'n'paste error or does it have some significance to your problem and if so, what? If it's somehow related to @sorted_array[5] (which is "2"), pray explain.

I won't claim that explanation is good for the soul, but yours would surely be a good aid to those of interesting in helping people learn Perl... which is one key to what this site is about. See I know what I mean. Why don't you?

Come, let us reason together: Spirit of the Monastery

If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1072149]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-11-24 15:42 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (350 votes). Check out past polls.