in reply to Standardized Template

The reason you are not getting all the entries is that some entries don't exist in some of the files. If you want all of the logins to be handled for all of the files, you will need to keep a global inventory of all the files and all the logins.

While using one of the modules designed to parse this data might be a good idea, it does not solve your problem.

Here's an untested rewrite:

my %USERS; my @all_strips = (); ## <-- new foreach my $file (<passwds.*>) { open(PASSWD,$file) or warn "Could not open $file:$!\n", next; my $strip=$file; #strips passwd. from passwd.server $strip =~ s/passwds\.//; push(@all_strips, $strip); ## <-- new while(<PASSWD>) { my($login,$gcos) = (split(':',$_))[0,4]; $USERS{$login}{$strip} = 1; ## This way you keep track of ## which login/strip combinations ## have been seen } close(PASSWD); } open(NEWFILE,">file3") or die "Can't open file3: $!\n"; foreach my $login (sort keys %USERS) { print NEWFILE "$login:", # Substitute X in where no strip was found join(':', map { $USERS{$login}{$_} ? $_ : 'X' } @all_strips), "\n"; } close NEWFILE; print "the Active Servers listing is done\n";