in reply to Re^3: problem with foreach statement
in thread problem with foreach statement
1. i need error 50 and 52 in one file and i have no clue how i can do it with this HoHIf you have a HoH where the primary key is the error code (22 24 50 52 79), the secondary keys can include not only the "msisdn" values from the log files, but also things like text strings that you want to associate with each type of error, the name of the file where you want to write information about each type, etc.
2. for each error i need to write a different text
3. i need to write for error 79 all MSISDN in a seperate textfile but again i dont know how to get them out of the HoH
Starting from my version of the code posted above, you could skip the use of the "@errorcodes" array, and instead initialize the "%adv" HoH as follows:
Then, when you get to the part near the bottom of the script where you loop over the various error codes to handle the "adv*.txt" files and send out mail messages, you can look up the filename and the message text for each error code in "$adv{$errcode}{filename}" and "$adv{$errcode}{message}".my %adv = ( '22' => { filename => "adv22.txt", message => "Text for error code 22" }, '24' => { filename => "adv24.txt", message => "This about error 24" }, '50' => { filename => "adv50_and_52.txt", message => "Text for error 50" }, '52' => { filename => "adv50_and_52.txt", message => "This is about error 52" }, '79' => { filename => "adv79.txt", message => "Special text for code 79" }, }; }
Meanwhile, the "$msisdn" strings that are also being used as secondary hash keys in %adv will continue to work (so long as these strings never turn out to be "filename" or "message", which would overwrite the initial values assigned above).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: problem with foreach statement
by ultibuzz (Monk) on Feb 16, 2006 at 07:33 UTC |