# 1193725.pl use strict; use warnings; use Path::Tiny qw/ path /; use List::Util qw/ uniq /; my $dir = '.'; my $iterator = path( $dir )->iterator; while( my $file = $iterator->() ) { next unless $file =~ /\.txt$/; my @lines = path( $file )->lines({ chomp => 1 }); path( $file )->spew( join "\n", uniq @lines ); } __END__