#!/usr/bin/perl -w use strict; my $user; my $tty; my $count; my @where; my %count = (); my %where = (); foreach $_ (`who`) { ($user,$tty) = /(\S+)\s+(\S+)/; $count{$user}++; $where{$user}{$tty}++; } foreach (sort keys %count) { if ($count{$_} == 1) { print "user $_ is ONLY logged in at one place "; print $where->{$_}; } else { print "user $_ is logged in at: "; @where = sort keys %{$where{$_}}; print "@where\n"; } } ~