in reply to trying to decide best data structure for problem at hand.
I'd key by name then uid:
use strict; use warnings; my %entries; my $key; my $host; while (<DATA>) { chomp; next if ! length; if (m|^/|) { $host = $_; } elsif (/(\w+)\s+(\d+)\s+(\d+)\s+(.*)/) { my ($name, $uid, $gid, $gecos) = ($1, $2, $3, $4); $entries{$name}{$uid} = { # User data keyed by uid gid => $gid, gecos => $gecos, host => $host, }; } else { print "Can't parse >$_<\n"; } } my @unlike = grep {keys (%{$entries{$_}}) > 1} keys %entries; print "@unlike"; __DATA__ /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
Prints:
bjose
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: trying to decide best data structure for problem at hand.
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 | |
by mikejones (Scribe) on Jan 08, 2007 at 20:18 UTC | |
|