Adriano Allora wrote: > > Hi to all, Hello,
> I need a script to open all the files in a directory and count all the > words of them, but it doesn't work: > > use Text::ParseWords; > $folder = "pathname"; > opendir(KART, $folder); > foreach (readdir(KART)){ > if(grep /\.txt$/, $_){ > $filename = "$_"; > open(INPUT, $filename); ####this one does not work > while (<INPUT>) > { > @words = split; > $numero = @words; > } > print "in the file $filename there are $numero words \n"; > close(INPUT); > }} > closedir(KART); > > what's the tip I don't know? Here is one way to do it: @ARGV = <pathname/*.txt>; while ( <> ) { $total += split; if ( eof ) { print "in the file $ARGV there are $total words \n"; $total = 0; } } __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]