theantler has asked for the wisdom of the Perl Monks concerning the following question:
What is going on in the line
push (@{$ttys{$user}}, $tty );
I just cant get my head around, what is going on there ..does it fit a hash-key inside of an array index?.. I also dont understand why you would ever do that. I must have a fundamental misunderstanding going. Sorry .. Can anyone help me?
my %ttys = (); open(WHO, "who|"); while (<WHO>) { ($user, $tty) = split; push (@{$ttys{$user}}, $tty ); <--- WHAT ??? } foreach $user (sort keys %ttys) { print "$user: @{$ttys{$user}}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help wanted .. cant get my head around array of hash
by moritz (Cardinal) on Feb 25, 2010 at 09:27 UTC | |
|
Re: Help wanted .. cant get my head around array of hash
by planetscape (Chancellor) on Feb 25, 2010 at 10:14 UTC | |
|
Re: Help wanted .. cant get my head around array of hash
by cdarke (Prior) on Feb 25, 2010 at 10:43 UTC | |
by theantler (Beadle) on Feb 25, 2010 at 15:34 UTC | |
by 7stud (Deacon) on Feb 25, 2010 at 16:08 UTC | |
by theantler (Beadle) on Feb 26, 2010 at 07:13 UTC | |
by theantler (Beadle) on Feb 26, 2010 at 10:51 UTC | |
|