You can look at the man pages
perlreftut,
perlref and
perldsc for more info on using HoH and similar data structures. As for your specific "changes":
1. i need error 50 and 52 in one file and i have no clue how i can do it with this HoH
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
If 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.
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:
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" },
};
}
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}".
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).
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.