Re: [ILUG] Re: Need help with Perl script

From: Fergal Daly (fergal at domain esatclear.ie)
Date: Tue 23 May 2000 - 20:15:12 IST


At 19:36 22/05/00, Nick Murtagh wrote:
>On Sun, 21 May 2000, David O'Callaghan wrote:
> > $num_users = `w -h | wc -l`;
> > print "There are $num_users logged on to the system.";
> >
> > Although if there are users logged on multiple times it won't catch
> > that and you could get the line count in a perl-ier way...
>
>$num_users = `w -h | cut -f 1 -d ' ' | uniq | wc -l`;

At that stage I'd imagine the amount of time spawning programs etc
completely dwarfs doing it all in perl

%users = map {($user) = split(" ", $_); ($user, undef)} `w -h`;
$num_users = keys %users;

Fergal



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:15 GMT