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";

In reply to Re: Standardized Template by Roy Johnson
in thread Standardized Template by tux242

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.