in reply to Writing one File from Various Files in a Directory
It's been awhile since I've used this snippet, but it might get you started. I did take the data in the LOGFILE and import it into an Access database, so it will probably go into Excel without too much trouble.my $dir = "location of your file directory"; my $filename = "the location & name of your new file"; open (LOGFILE, ">$filename") or die "Can't create logfile: $!"; opendir (DATADIR, $dir) or die "Can't open $dir: $!"; while( defined ($file = readdir DATADIR) ) { next if $file =~ /^\.\.?$/; open (INFILE, "$dir\\$file") or die "Can't open $dir: $!"; print LOGFILE "$file|"; $/ = ''; while (<INFILE>) { @lines = $_; } foreach (@lines) { print LOGFILE $_; } } close (INFILE);
Also, I'm pretty new with Perl, so more than likely there's a better, shorter way to do it that a more experienced Monk could share.
HTH,
WB
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Writing one File from Various Files in a Directory
by CountZero (Bishop) on Jun 21, 2003 at 06:53 UTC | |
by WhiteBird (Hermit) on Jun 21, 2003 at 13:29 UTC |