Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have this script that finds users on a workstation but would like some explanation of the LoggedOnUsers function. I tried perldoc -q LoggedOnUsers and got nothing. Please explain this script so I can get a better understanding of this.
use strict; use Win32::NetAdmin qw(LoggedOnUsers); my %users; my $server = "111.111.111.111"; LoggedOnUsers( $server, \%users); #What is the \ doing with this hash + variable?? print "Users logged on to $server:\n"; for (keys %users) { my ($user, $udomain, $userver) = split /;/, $users{$_}; #Where does $udomain and $userver come from and represent?? print "USER: $user\n"; }

Replies are listed 'Best First'.
Re: LoggedOnUsers Function
by particle (Vicar) on Jun 24, 2002 at 11:36 UTC
    the backslash denotes a reference. you'll want to read perlreftut (off-site link--where's the local copy?) to get aquainted with references, and perlref for detailed information. additionally, you can read the docs for Win32::NetAdmin on CPAN.

    Update: crazyinsomniac asked me to point you to How to RTFM, which might help improve your chances at finding answers on your own. i see you tried the docs first, which is good. Masem's node will help you take better advantage of them.

    ~Particle *accelerates*

Re: LoggedOnUsers Function
by smitz (Chaplain) on Jun 24, 2002 at 11:54 UTC
    LoggedOnUsers returns a hash of users logged into $server into %users.

    Each entry is is then split into the variables $user, $udomain, $userver.

    HTH,
    SMiTZ