Example:
$cat file
I like oranges
I like apples
I like pears
I like apples
I like guavas
I like oranges
I like apples
$./test.pl file
I like apples
I like oranges
#!/usr/bin/perl
#
open(FILE,"$ARGV[0]");
my @contents =;
my %dup;
foreach $line (@contents)
{
@keyz = keys %dup;
if(!(grep(/$line/, @keyz)) || $dup{$line})
{
$dup{$line}++;
if($dup{$line} > 1)
{
print $line;
$dup{$line} = 0;
}
}
}
No comments:
Post a Comment