dcb0127 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use DirHandle; usage() if @ARGV < 1; my @files = (); while ( my $dir = shift @ARGV ) { my $dh = new DirHandle $dir; if ( defined($dh) ) { while ( defined($_ = $dh->read) ) { if ( $_ =~ /(\.csv)$/ ) { $dir =~ s/\/$//; push @files, "$dir/$_"; } } } } foreach my $file ( @files ) { open(INF,"$file") or dienice("Can't open data files"); @data = <INF>; close(INF); open(OUTF,">>combine.csv"); print "@data\n"; close(OUTF); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Combing Text Files into one file
by rbc (Curate) on Sep 17, 2002 at 22:10 UTC | |
by myocom (Deacon) on Sep 17, 2002 at 22:14 UTC | |
Re: Combing Text Files into one file
by Aristotle (Chancellor) on Sep 17, 2002 at 22:14 UTC | |
Re: Combing Text Files into one file
by runrig (Abbot) on Sep 17, 2002 at 22:16 UTC | |
Re: Combing Text Files into one file
by bronto (Priest) on Sep 18, 2002 at 08:30 UTC |