|
|
| P is for Practical | |
| PerlMonks |
hash to count wordsby underoathed (Initiate) |
| on Sep 13, 2012 at 14:05 UTC ( #993499=perlquestion: print w/ replies, xml ) | Need Help?? |
|
underoathed has asked for the
wisdom of the Perl Monks concerning the following question:
Ok PerlMonks got a question for you. How do I create a hash to count certain words? I have everything else set up properly except that. Also can anyone tell me what /g means in my code? Here is my code.
<code>
#! /usr/bin/perl -w
foreach $file (ARGV) {
open (IN, $file) or die "Cannot open '$file' : $!\n;
$line = <IN>;
@array = split (' ', $line);
foreach $word (@array){
$word =~ s/^\w\x\//g;
$word = lc ($word);
%hash = ();
%hash_ref = $word;
print "word\n":]
close (IN); }
</c>
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||