in reply to parse multiple text files keep unique lines only
# 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__
Hope this helps!
Update: Removed example output as it was distracting (after rereading question and amending example).
|
|---|