in reply to Re: reference question
in thread reference question

Something wrong ...
~/script/perl/temp@myserver >cat !$ cat ./perl.tty4 #!/usr/bin/perl -w use strict; my %ttys_of; foreach (`who`) { my ($user, $tty) = /(\S+)\s+(\S+)/; push @{$ttys_of{$user}}, $tty; } foreach my $user (sort keys %ttys_of) { my $ttys = @{$ttys_of{$user}}; if (@$ttys == 1) { print "user $user is ONLY logged in at one place $ttys +->[0]\n"; } else { print "user $user is logged in at: " . join(' ', sort +@$ttys) . "\n"; } } ~/script/perl/temp@myserver >./!$ ././perl.tty4 Can't use string ("1") as an ARRAY ref while "strict refs" in use at . +/./perl.tty4 line 15. main::(././perl.tty4:13): my $ttys = @{$ttys_of{$user}}; DB<1> main::(././perl.tty4:13): my $ttys = @{$ttys_of{$user}}; DB<1> main::(././perl.tty4:15): if (@$ttys == 1) { DB<1> Can't use string ("1") as an ARRAY ref while "strict refs" in use at . +/./perl.tty4 line 15, <IN> chunk 142. Debugged program terminated. Use q to quit or R to restart, use O inhibit_exit to avoid stopping after program termination, h q, h R or h O to get additional info.

Replies are listed 'Best First'.
Re^3: reference question
by wind (Priest) on Jul 29, 2007 at 04:20 UTC
    Sorry about that. That's why one should not play around with more than one version of code before posting their solution. I temporarily thought about dereferencing the array to make it simpler to access in the loop. But I personally would never do this, so I removed the temporary simplification ... almost.

    The code has been updated with the correction.

    - Miller