Hello,
I am about to finish a perl script but it takes very long to run as I am
using three foreach loops one after the other. I have three files with
data passed into hashes:
FileA keyA = 12345
valueA = abcdefgh
FileB keyB = 67890
valueB = ijklmno
FileC keyC = 12345:67890 (key from 1st file)
valueC = 12345:67890 (key from 2nd file)
I am trying to print keyA followed by valueA and then find the
corresponding partner in FileB using FileC and then to print that keyB
and its valueB into a file. I have 10000 key-value pairs in each hash
FileA and FileB so in the end I will have 10000 files, so that output
file1 (name =keyA:keyB ) will look like:
FileA keyA = 12345
valueA = abcdefgh
FileB keyB = 67890
valueB = ijklmno
At the moment my syntax towards the end is a bit like:
foreach $keyC (keys hashC) {
foreach $keyB (keys hashC) {
foreach $keyA (keys hashA) {
if ($keyC =~ $keyB && $keyC =~ $keyA ) {
print "keyA\n$hashA{keyA}\n\n$keyB\n$hashB{keyB"
}
}
}
As you would expect there are 10000 keys in each of the three files so
thats e+12 searches and it is taking very long. Does any one know a
quicker way of doing this.
Cheers. aim
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]