#!/usr/bin/perl -w foreach $file (@ARGV) { open (IN, $file) or die "Cannot open file '$file' : $!\n"; while(<>) { $line = <IN>; @array = split (' ', $line); foreach $word (@array){ $word =~ s/[^\w\s]//g; $word = lc ($word); $wordcount{$word} += 1; } } foreach $key (keys %wordcount) { print "Word: $key " . ($wordcount{$key}) . "\n"; } } print ("scriptOutput\n\n");
In reply to Re^5: hash to count words
by underoathed
in thread hash to count words
by underoathed
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |