in reply to Re: search and replace
in thread search and replace

if the index is just a running number just use only one array  $dict[$column1] = $column2.
BTW replacement becomes easy (by checking with exists/defined $dict[$number] and then replace).
UPDATE:
I just misunderstood the question, pardon me.
It is solvable using hash itself.

Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.

Replies are listed 'Best First'.
Re^3: search and replace
by bellaire (Hermit) on Mar 17, 2009 at 11:43 UTC
    This wouldn't work as well because he needs to find the words in his string, and use the numbers to replace them. That is, the index should be the data from the input file, which is words, not numbers. Using the numbers as the index would force him to search the entire list for each word which needs to be replaced (although it would save him one array compared with his current two array approach). Using the words themselves as hash keys allows him to do a simple lookup.