Hi blue cowdawg
I tried your sub, but it still does not work. ".:Permission denied at project6.pl line 16." Which is open FIN,"< $fname" or die "$fname:$!"; Any idea why this happens?
#!/usr/bin/perl -w
use strict;
my $dir = 'C:\Users\Zandre Botha\Desktop\Text Files';
opendir (DIR, $dir) or die "cannot opendir $dir";
foreach my $file (readdir(DIR))
{
&process_file ($file);
}
sub process_file
{
my $fname=join("/",@_);
open FIN,"< $fname" or die "$fname:$!";
my @lines=<FIN>;
chomp @lines;
close FIN;
my $count=0;
foreach my $line(@lines)
{
map { $count++ } split (/[\s\t\n]+/,$line);
}
printf "There are %d words in %s\n",$count,$fname;
}
closedir (DIR);