in reply to Using Positions from one array to find the value in the same position of another.

This sounds like an xy+problem. You have expressed some ideas about how to achieve something without detail on WHAT you are trying to achieve.

for Lookups, a hash would be a much better structure. Are you trying to come up with some sort of encryption scheme ?

A few pointers:
* @words would probably work better as %words (a hash).
* When you do I/O using <>, you most likely need a "chomp"
* If @numbers2 contains 0..40K in random order, why not sort it, so it is indexed easier ?
Alternatively, create an index array that indirectly accesses @numbers2.

In any case .. let us know what you want to build, and I'm sure you will get many helpful suggestions, and perhaps, even code.

        This is not an optical illusion, it just looks like one.

  • Comment on Re: Using Positions from one array to find the value in the same position of another.

Replies are listed 'Best First'.
Re^2: Using Positions from one array to find the value in the same position of another.
by AnomalousMonk (Archbishop) on Apr 29, 2016 at 20:33 UTC

    Try XY Problem instead.   (xy+problem is actually an N-problem: it is Non-existent. :)


    Give a man a fish:  <%-{-{-{-<

Re^2: Using Positions from one array to find the value in the same position of another.
by RuZombieSlayer (Novice) on Apr 29, 2016 at 20:35 UTC
    Yes a form of encryption is the final result, this is just a step but the idea is to use a sentence determind by <> and push each word into an array. @numbers2 is in a random order because i want it to be, on my computer there are 26 random lists like @numbers2 to be used to switch out ID's. Because if someone knew the 6 digits where positions of a word in the language, they could just get their own list and count till they found the word. The purpose of the random @numbers2 is to switch the 6 digit keys that represent position with othe random 6 digit keys. So far i have been thinking about and am thinking of making a hash where keys are numbers (0..$#numbers2) and values are @numbers 2 so that when i give it position 0 (for the word "a" it will return a random number such as 300460 etc. Your right when i go back and optimize this i may well just make @words a %hash