in reply to Re: parse multiple text files keep unique lines only
in thread parse multiple text files keep unique lines only

Don't use File::Slurp, it's broken.


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^3: parse multiple text files keep unique lines only
by tybalt89 (Monsignor) on Jun 28, 2017 at 13:05 UTC
    #!/usr/bin/perl # http://perlmonks.org/?node_id=1193719 use strict; use warnings; use File::Find; use Path::Tiny; my $directory = 'some/test/'; find sub { my %u; -f and /\.txt$/ and path($_)->edit_lines( sub { $_ x= !$u{$_}++ } ) }, $directory;

      With Path::Tiny, you don't need File::Find.

      #!/usr/bin/perl # http://perlmonks.org/?node_id=1193719 use strict; use warnings; use Path::Tiny; my $directory = 'some/test/'; path($directory)->visit ( sub { my %u; -f and /\.txt$/ and $_->edit_lines ( sub { $_ x= !$u{$_}++ } ) } );