Perhaps something like the following might help you:
my $filename = "anything.ldif";
unless (open (LDIF, $filename)) {
die "Error: couldn't read from '$filename': $!\n";
}
else {
my %seenObjects = ();
local $/ = "\n\n"; # read objects, not lines
while (<LDIF>) { # $_ has one object now
chomp($_);
s/\n //g; # kill continuation lines
if ($seenObjects{$_}++) {
# object already seen... write to another filehandle
print OUTFILE "$_\n\n";
} # if
} # while
close (LDIF);
} # else
(Code not tested)
If the LDIF file is very big, you could either save the Digest::MD5 of the object:
use Digest::MD5 (); # no namespace pollution
...
if ($seenObjects{ &Digest::MD5::md5_hex($_) }++) {
...
or sort the LDIF (e.g. with Tie::File) and compare one line with its precessor.
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32" |