in reply to Building data structure from several /etc/passwd files
Using a wildcard for the filename is easy enough, just use the glob() operator... As for the other part of the question, I'm not sure what you are asking but it sounds like you want to keep track of which users had accounts on which machines. I'd probably do the whole thing something like this:
#!/usr/bin/perl -w use strict; my %USERS; foreach my $file (<passwd.server*>) { open(PASSWD,$file); while(<PASSWD>) { my($login,$gcos) = (split(':',$_))[0,4]; if(exists $USERS{$login}) { push(@{$USERS{$login}},$file); } else { $USERS{$login} = [$gcos,$file]; } } close(PASSWD); } open(NEWFILE,">endo"); foreach my $login (sort keys %USERS) { print NEWFILE "$login:".shift(@{$USERS{$login}}).":"; print NEWFILE join(',',@{$USERS{$login}})."\n"; } close(NEWFILE);
| We're not surrounded, we're in a target-rich environment! |
|---|
|
|---|