dcb0127 has asked for the wisdom of the Perl Monks concerning the following question:
I have a script that opens up html files strips them and places the text into .txt files. I want to be able to combine all the .txt files that the first script did into one file and I'm having problems with the coding. I'm new at this so please excuse the poor scripting. Thanks
#!/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 |
Back to
Seekers of Perl Wisdom