in reply to Re: Multidimensional Hash implementation/usage
in thread Multidimensional Hash implementation/usage

Hello Moritz,

Thank you for your time on this. The code snippet is the original translation of the AWK script. I posted that as the actual one has a lot of extra code functionality included and I have been using "my", "strict", "warnings" as mentioned in the Llama book from the first line :-)

I am actually having trouble getting a visual representation of the 3 dimensional hash here. I guess I should have been reading more on data structures :-(

$CNT{$idx}{$Fld1}{$Fld15}++;

Is it that, in %CNT the first key ($idx) has the value of another hash that has the key $Fld1 and that again refers to another hash with key $Fld15 - which has its value incremented?
Please let me know if you need any further information on these and I can email you the full code along with necessary files if required.
Thanks again for your help :-)
Subhankar

Replies are listed 'Best First'.
Re^3: Multidimensional Hash implementation/usage
by moritz (Cardinal) on Sep 17, 2007 at 07:28 UTC
    %CNT contains indeed another hash for each key, which in turn will contain another hash which in turn contains the "real" data.

    If you want to visualize your data structures, use Data::Dumper:

    use Data::Dumper; ... print Dumper \%CNT;
      Hello Moritz,

      Thank you very much. That really helped. I think I am begining to get a grip now.

      Cheers!
      Subhankar

Re^3: Multidimensional Hash implementation/usage
by graff (Chancellor) on Sep 17, 2007 at 13:04 UTC
    The code snippet is the original translation of the AWK script.

    That probably explains where this line came from:

    $[ = 1; # set array base to 1
    If you have a lot of other stuff to add to your perl script, you almost certainly want to make sure to DELETE THAT LINE.

    (If you have already written the additional code, and have made all the adjustments needed to accommodate the non-standard value for $[, that's unfortunate. Still, you should consider deleting that line anyway, and adjusting everything back to "normal".)

    I had never seen or used "a2p" before (I never did a lot of awk scripting). Now that I've seen what it does If the OP code is really an example of what it does, I think I'll avoid it.