in reply to iterating hash keys?
and iterate through all the hash keys
The major purpose of hashes is that you can lookup the value associated with any key directly, avoiding iteration.
For your purpose, the major part of the code should be something like:
while( <$names_to_be_replaced_file> ) { ## read each line s[\b([a-z]+)\b][ $name_id{ $1 } ]ge; ## find words, look them up + and replace them with the id print; ## Send the modified lines +to stdout }
Simple and very efficient.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: using hashes
by R56 (Sexton) on Sep 26, 2013 at 16:51 UTC | |
by BrowserUk (Patriarch) on Sep 26, 2013 at 17:09 UTC | |
by R56 (Sexton) on Sep 26, 2013 at 18:21 UTC | |
by hdb (Monsignor) on Sep 26, 2013 at 17:30 UTC | |
by aaron_baugher (Curate) on Sep 26, 2013 at 17:16 UTC |