Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Extract information from several files in directory

by Tux (Canon)
on Nov 28, 2020 at 09:38 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11124312]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2024-04-19 00:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found