Perl Help - TechRepublic
Question
February 9, 2008 at 07:15 AM
eightball_20012001

Perl Help

by eightball_20012001 . Updated 18 years, 4 months ago

I am trying to write a perl script that will read a document and count the occurrence of specific words through a hash. With what I have, I can get it to print out each word “word was found ”
But i cannot get a value after found. Please help.

open (PASSW,’<', 'ready.txt'); @k = /\w+\b.good|\b.serious|\b.match|.truly|.read/; while (@k = ) {
chomp;
%pass_hash = (‘good’ => $_ , ‘serious’ => $_, ‘match’ => $_ , ‘truly’ => $_ , ‘read’ => $_);
@k = keys %pass_hash;
while () {
$count{$_}++ for /\w+\b.good|\b.serious|\b.match|.truly|.read/ ;
}
foreach $pass(@k) {
print “The $pass was encountered $count{$_} \n”;}

}

This discussion is locked

All Comments