http://www.perlmonks.org?node_id=198667

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); }