Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Using perl to extract data from multiple .txt files

by blue_cowdawg (Monsignor)
on Nov 14, 2012 at 16:26 UTC ( #1003849=note: print w/ replies, xml ) Need Help??


in reply to Using perl to extract data from multiple .txt files

use strict; opendir(INDIR,"/path/to/directory/with/files") or die $!; while (my $fname = readdir(INDIR)){ next unless $fname =~ m@\.txt$@; open FIN," < $fname" or die "$fname: $!"; my @stuff=<FIN>; close FIN; #process lines.... }
There's another way of doing it.


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg


Comment on Re: Using perl to extract data from multiple .txt files
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2015-03-31 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:









    Results (660 votes), past polls