my %passwd; my %smbpasswd; while (<PASSWD>) { next if /^#/; chomp; my ($name, $uid) = (split ':', $_, 4)[0,2]; $passwd{$uid} = $name; } # Do the same for SMBPASSWD, except use [0,1] instead of [0,2] foreach my $uid (keys %passwd) { unless (exists $smbpasswd($uid}) { print "'$uid' in passwd, not in smbpasswd\n"; next; } # Deleted to do later comparison my $smb_name = delete $smbpasswd{$uid}; unless ($passwd{$uid} eq $smb_name) { print "$uid has $passwd{$uid} in passwd, but $smb_name in smbb +passwd\n"; } } while (my ($k, $v) = each %smbpasswd) { print "$k in smbpasswd, not in passwd\n"; }
------
We are the carpenters and bricklayers of the Information Age.
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
In reply to Re: Compare csv file fields?
by dragonchild
in thread Compare csv file fields?
by traveler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |