You could also do something like this.
foreach $uid (%file1)
{
if ( ($file1{$uid} =~ /$file2{$uid}/) || ($file2{$uid} =~ $file1
{$uid}))
{
print "A duplicate has been located\n";
}
}
"The right word may be effective, but no word was ever as effective as a
rightly timed pause."
--Mark Twain
|---------+---------------------------->
| | "Rob Dixon" |
| | <[EMAIL PROTECTED]|
| | m.co.uk> |
| | |
| | 06/11/2003 03:24 |
| | PM |
| | |
|---------+---------------------------->
>------------------------------------------------------------------------------------------------------------------------------|
|
|
| To: [EMAIL PROTECTED]
|
| cc:
|
| Subject: Re: Two lists...
|
>------------------------------------------------------------------------------------------------------------------------------|
James Kelty wrote:
> Say I have two large lists of names (uid's). I would like to look at
> both of these files and make sure that a name (uid) doesn't appear in
> BOTH files. Just one or the other. Not sure how to handle that. Any
ideas?
The short answer is
perldoc -q duplicate
The long one is, what does 'make sure' mean? I can think of several
ways, all more or less destructive, to make sure there are no duplicates
between the files. But how about this code to /find out/ if
there are duplicates; then you can wreak whatever destruction is
appropriate.
my %uids = do {
local @ARGV = 'file1';
map { ($_, undef) } <>;
};
my $already = do {
local @ARGV = 'file2';
grep {exists $uids{$_}} <>;
};
if ($already) {
:
}
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]