tux242 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, I have a loop condition I need to take $login and run it thorugh an equality check of a array type listing, look at the code below:
foreach my $file (<passwd.*>){ open (PASSWD,"$file"); $nf="file1"; open (NEWFILE, ">$nf"); while (<PASSWD>) { ($login, $passwd, $uid, $gid, $gcos, $home, $shell) = split(/:/); $USERS{$login} = $gcos; } close (PASSWD); } foreach $login (sort keys %USERS) { $gcos = $USERS{$login}; @SKIP = ('adrian','adm','sys','alcatel'); foreach $login ($SKIP) { next if $login eq $SKIP; } #next if ($login =~ /adrian|adm|sys|alcatel/); print NEWFILE "$login\n"; } close (NEWFILE);
anyone tell me where I am going wrong, I simply want to skip the $login(s) in the @SKIP array. Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: next if loop
by Abigail-II (Bishop) on Nov 19, 2003 at 21:15 UTC | |
by hardburn (Abbot) on Nov 20, 2003 at 19:08 UTC | |
by Abigail-II (Bishop) on Nov 20, 2003 at 19:48 UTC | |
by davido (Cardinal) on Nov 20, 2003 at 19:15 UTC | |
|
Re: next if loop
by hardburn (Abbot) on Nov 19, 2003 at 21:12 UTC | |
|
Re: next if loop
by liz (Monsignor) on Nov 19, 2003 at 21:06 UTC | |
by hardburn (Abbot) on Nov 19, 2003 at 21:16 UTC | |
|
Re: next if loop
by Zaxo (Archbishop) on Nov 20, 2003 at 06:15 UTC |