# here is an example to get you started in untested code. my ($in, $out, %hash); open $in, "<", $file_name; # you set the name somewhere else open $out, ">", $out_file; local $/ = "@:"; # set the input record seperator while (<$fh>) { if ($hash{$_}++) { # will be undef first time then >0 print "Warning duplicate found\n$_"; } else { print $out $_ } }