Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Er...

by Nkuvu (Priest)
on Feb 10, 2003 at 21:47 UTC ( #234250=note: print w/replies, xml ) Need Help??


in reply to Finding the size of an array in a hash?

Correct me if I'm wrong (which wouldn't be too much of a surprise), but isn't
push @{$FULLLINES{$account}}, “$lines”;
creating an array of hashes?

This is a very different thing than a hash of arrays.

Replies are listed 'Best First'.
Re: Er...
by PodMaster (Abbot) on Feb 10, 2003 at 22:11 UTC
    No it is not. It's essentially the same as
    my $aRR = []; push @$aRR, $lines; $FULLINESS{$account} = $arr;
    See what i'm saying?


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    ** The Third rule of perl club is a statement of fact: pod is sexy.

Re: Er...
by Solo (Deacon) on Feb 10, 2003 at 22:26 UTC
    Actually, push @anything, "$lines" creates an array of scalars, which is why jeffa warns against it--since it may not be what you wanted.

    To your original question, push @{$FULLLINES{$account}}, “$lines”; is populating an anonymous arrayref for key $account in the %FULLLINES hash. %FULLLINES would look something like this:

    ( 'account1' => [ 'lines','lines', ], 'account2' => [ 'lines', ], )

    When in doubt, you can

    use Data::Dumper; print Dumper(\%FULLLINES);
    --
    You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.
      Hrm. I'll have to take your (that's a "your" plural, btw) word for it. This is why I don't use hashes of arrays or arrays of hashes.

      I've had to update some scripts by co-workers who use variables like $rvw (your guess is almost as good as mine on what that variable represents (my only advantage is I have some context)) and insane compositions such as the above (actually the above make the compositions I'm dealing with look like cake sometimes). And of course the previous developer didn't know what a comment was. They're always hard for me to decipher, and are a good indication on why people think Perl looks like line noise...

      Anyway, thanks for the clarification.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://234250]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2019-03-26 18:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How do you Carpe diem?





    Results (125 votes). Check out past polls.

    Notices?