~/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.
In reply to Re^2: reference question
by convenientstore
in thread reference question
by convenientstore
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |