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

Re: Extract information from several files in directory

by AnomalousMonk (Bishop)
on Nov 27, 2020 at 21:23 UTC ( #11124298=note: print w/replies, xml ) Need Help??

in reply to Extract information from several files in directory

This won't help you at the moment, but for future reference, keep in the back of your mind the modules Text::CSV, which is pure Perl, and the closely related Text::CSV_XS, which does the same things only faster, but requires local compilation that can be problematic.

These modules do lots of stuff and can be a great help when processing | reading and writing CSV files of any kind. However, their learning curve, while quite reasonable, is steep enough that you may wish to simplify your current situation by sticking close to what you know.

Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Extract information from several files in directory
by Tux (Abbot) on Nov 28, 2020 at 09:38 UTC

    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?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2021-01-19 02:36 GMT
Find Nodes?
    Voting Booth?