Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Extract information from several files in directory

by Tux (Canon)
on Nov 28, 2020 at 09:38 UTC ( #11124312=note: print w/replies, xml ) Need Help??


in reply to Re: Extract information from several files in directory
in thread Extract information from several files in directory

If you start simple, Text::CSV_XS' interface does not have a steep learning curve at all :)

If all your text files have a header, and you want "column" fooble extracted from all TAB-separated .txt files

use strict; use warnings; use Text::CSV_XS qw( csv ); my @result; foreach my $f (sort glob "*.txt") { # Use File::Find for recursive act +ions csv (in => $f, headers => "auto", sep => "\t", on_in => sub { push @result => $_{fooble}; }); } open my $fh, ">", "results.txt" or die $!; say $fh $_ for grep { length } @result; close $fh;

Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2021-04-22 16:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?