|Welcome to the Monastery|
Multidimensional Hash implementation/usageby subhankar (Novice)
|on Sep 17, 2007 at 06:24 UTC||Need Help??|
subhankar has asked for the
wisdom of the Perl Monks concerning the following question:
I am a newbie to Perl and I have been trying to work with it since the last few days.
There's an awk script, which works but I have been told to use Perl to rewrite the same as we need Perl's formatting capabilities. I converted the AWK script to Perl using a2p. The code :
There is a pipe separated file from which certain fields are to be extracted and based on the occurence of a particular type of field, the count has to be gathered. I have cleaned up the initial part of the code where the lines are splitted and the values extracted. Currently I am unable to figure out the implementation of the 3 dimensional hash as in :
It would be very helpful to me if someone could explain in simple terms, how is this auto-increment and the addition getting done. The foreach loop gets the values from the %CNT, but I also need the corresponding %COST value in the same line.
Although I am able to get the values, any help in understanding the hash mechanism implemented here, would be very helpful.