I have ActivePerl 5.6.0 on Win2000 (in a DOS box). I want to
find all .CSV files starting in the directory where the perl
script is. I have a program but no files are processed. Can
someone help me to get this to work? Here is the code:
#########################################################
use File::Find;
#... some other code
# Main code begins here.
find(\&proc_file,'.');
close(OUTFILE);
print "\nDone. Wrote file to $outfile.\n";
exit;
######################## end of main ###########################
sub proc_file
# Process filename in $File::Find::name or $_.
# This actually changes to the dir where the file is found.
{my(@lin,$i,$l,$s);
if (!(-e $_))
{print "$_ does not exist.\n";
return;
}
if ($Find::File::name !~ m/\.csv$/) # Process only csv files.
{return;
}
if (!(-T $Find::File::name)) # If not a text file, return.
{return;
}
print "Processing $_\n";
open(INFILE, $_) || die "Could not open $_. $!";
@lin=<INFILE>;
chomp(@lin);
writeln("<begtab>");
for ($i=0; $i<=$#lin; $i++) # Process each line.
{
$l=$lin[$i];
$l=~s/,/<Tc>/;
$l="<Tr>" . $l;
writeln($l);
} # for
writeln("<endtab>");
close(INFILE);
return;
} # proc_file
#########################################################
--
__________
Freezone Freeware: http://chuckr.bravepages.com
http://freezone.darkstar.co.nz
900+ programs in 40+ categories. Links to 450+ free Delphi
controls in 20+ categories!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]