mikejones has asked for the wisdom of the Perl Monks concerning the following question:
to acheive my goal which is to find un-alike uids so in the above file I would print out bjose and his respected 4 fields. I was thinking of multiple hashes with multiple keys. My keys would be hostname.platform and the values would be the fields above name,uid,gid,gecos because I need to identify on what host each user-id with un-alike uid lives. Here is my code thus far, thank you!/var/tmp/passwd.hostname1.platform nguyenhe 1929 20 Henry Nguyen,555-555-555 bjose 1990 20 Bobby Jose,x3338 .... .... .... /var/tmp/passwd.hostname2.platform vjain 2098 20 Vineet Kumar Jain, offshore llai 2122 20 Levius Lai bjose 1995 20 Bobby Jose,x3338 ... ... ...
use strict; use warnings; use diagnostics; my $awksh = qq(/home/awk_parse_passwd.ksh); my $log = qq(/tmp/uid_ck.log); my ($k,$v,$element,$line) = 0; my (@keys,@values,@glob) = (); my (%hosts,%mcg_hosts) = (); open (LOG, ">>$log") or warn "file: '$log' did not open $!"; open (AWKSH, "$awksh -|") or die "unable to spawn '$awksh' $!"; { local $/ = 'undef'; foreach $line (<AWKSH>) { (@glob) = glob("/home/passwd.*"); } } foreach $element (@glob) { ($keys[$k++]) = $element =~ m|\.(\w+\.\w+)\z|ig; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trying to decide best data structure for problem at hand.
by rodion (Chaplain) on Dec 30, 2006 at 05:24 UTC | |
|
Re: trying to decide best data structure for problem at hand.
by GrandFather (Saint) on Dec 30, 2006 at 05:07 UTC | |
by mikejones (Scribe) on Jan 03, 2007 at 21:50 UTC | |
by GrandFather (Saint) on Jan 03, 2007 at 22:05 UTC | |
by mikejones (Scribe) on Jan 05, 2007 at 20:48 UTC | |
by GrandFather (Saint) on Jan 06, 2007 at 11:46 UTC | |
| |
|
Re: trying to decide best data structure for problem at hand.
by sauoq (Abbot) on Dec 30, 2006 at 05:01 UTC | |
|
OT: you could use a directory too
by f00li5h (Chaplain) on Jan 04, 2007 at 11:49 UTC |