Hello All,

OK, I'm very new to Perl, so please don't flame me!

I need to read in every file in a dir into a new file.  I can do it like
below if I know the file names, but how can I specify *.CSV?  Actually there
will be only the data files I need to read in the dir so *.* would work as
well.  Perhaps I should also mention this is running on Win 2K.

Can I build an array (@Files)of file names and just call $Files[$i] instead
of each file and increment i between files?  If so, how would I build an
array from a "dir *.*" command and how would I be sure not to include
erroneous info returned?

Is there a much better way to combine these files in order by name?

Code I have now:

#!/usr/bin/perl -w
open(F1,"C:/Temp/0912.CSV") || die "Couldn't open F1.\n"; #Open File 1
open(F2,"C:/Temp/0913.CSV") || die "Couldn't open F2.\n"; #Open File 2
open(F3,"C:/Temp/0914.CSV") || die "Couldn't open F3.\n"; #Open File 3
open(F4,"C:/Temp/0916.CSV") || die "Couldn't open F4.\n"; #Open File 4
# Yada yada ya...
open(STAT,">C:/Temp/Stats.CSV") || die "Couldn't open STAT.\n"; #Create
Stats file
while(<F1>) {
        print STAT; #Print F1 -> Stats
}
while(<F2>) {
        print STAT; #Print F2 -> Stats
}
while(<F3>) {
        print STAT; #Print F3 -> Stats
}
while(<F4>) {
        print STAT; #Print F4 -> Stats
}
# Yada yada ya...

I would also like to strip the first row from every file EXCEPT the first,
or possibly from all and insert header row into Row 1 of resulting stats.csv
file.  Any suggestions on that?

Thanks for any insight!
Bill A.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to