All,
Monumentally basic question here (but hey, this is what this list is for,
yeah?).
I'm working on my first ever useful script (after "Hello World" and "Enter a
number" "Wrong!" type things). It's also my first ever foray into
programming of any kind, so please make sure answers are in layman's
terms...!
Part of the script is to compare 2 string arrays, and produce a third array
that contains the exclusive members (more accurately, a list of users on one
machine, compared to a list of new users - do any of the new users already
have an account? If not, stick them in another array for later). Here's the
script I got straight out of "The Perl Cookbook" to do this (allegedly):
open (EXIST, "/tmp/users");
@exist = <EXIST>;
close (EXIST);
%lookup = ();
@users = ();
foreach $item (@exist) { $lookup{$item} = 1 }
foreach $item (@new_users)
{
unless ($lookup{$item})
{
push(@users, $item);
}
}
First of all, can someone explain what this is doing in simple terms (as I
haven't started playing with hashes yet), and secondly, when I ran it on a
test file (forming @new_users) it still passed on a username that already
exists to the rest of the script.
I'm running Solaris 2.5 and Perl 5 by the way.
Appreciate any help.....
Rgds
Stuart Watts
System Test Engineer
Motorola S.T.G. Swindon
Stuart Watts (Contact).vcf