Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: parse multiple text files keep unique lines only

by 1nickt (Canon)
on Jun 28, 2017 at 08:02 UTC ( [id://1193770]=note: print w/replies, xml ) Need Help??


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{$_}++ } ) } );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1193770]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-23 12:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found