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

Re: Opening multiple files in directory

by olus (Curate)
on Mar 18, 2009 at 21:58 UTC ( #751583=note: print w/ replies, xml ) Need Help??


in reply to Opening multiple files in directory

This works for me. Adjust as convenient.

use strict; use warnings; use Data::Dumper; my $some_dir = "."; opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!"; my @files = grep { /txt/ } readdir(DIR); closedir DIR; foreach my $f (@files) { open IN, "<$f"; my @cmpids = (); while(<IN>) { push @cmpids, $_; } close IN; open OUT, ">>COID_LIST.TXT"; print OUT Dumper(\@cmpids); close OUT; }


Comment on Re: Opening multiple files in directory
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2015-07-31 00:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls