in reply to Re^3: Perl and arrays of arrays?
in thread Perl and arrays of arrays?

Oops, I should have replied to the original post.

The comment was meant to be an indicator of the usage, I wasn't worried about making it syntactically correct.

I personally like the hash of arrays approach, as it more closely mirrors the way I think about the problem: a key (IP address) that can have one or more aliases. However, as I noted in my original post, it is not the most efficient way to do things...just a bit easier to understand for a beginner IMHO.

Replies are listed 'Best First'.
Re^5: Perl and arrays of arrays?
by QM (Parson) on Aug 17, 2005 at 20:44 UTC
    I personally like the hash of arrays approach, as it more closely mirrors the way I think about the problem: a key (IP address) that can have one or more aliases. However, as I noted in my original post, it is not the most efficient way to do things...just a bit easier to understand for a beginner IMHO.
    I understand what you're saying, but I'd go in a different direction.

    If a beginner understands AoA:

    $array[$row][$col] = $pixel;
    and that hashes are sort of arrays with different brackets:
    $array{$row}{$col} = $pixel;
    then it's a small leap to suggest that (here, at least) the keys are the interesting bits, and the values don't matter:
    $hosts{$ip}{$alias} = 1;

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      Yeah, when you put it that way, I see what you mean. Not to mention the fact that the HoH method is far more scalable because you don't have to explicitly filter duplicates. TMTOWDI :)