Hi,
here is the code:
use warnings;
open(FILEHANDLE ,"school.txt ") or die"Couldn't open file:$!";
while ($line = <STDIN>)
{
while ($line =~ s/(\w+)(.*)/$2/)
{
$word = $1;
$wordHash{$word }++;
}
}
while (($word, $count) = each(%wordHash) )
{
$wordHash[$i] = "$word\t$count" ;
$i++;
print ("$word\n");
}
close(FILEHANDL E);
here is the code:
use warnings;
open(FILEHANDLE ,"school.txt ") or die"Couldn't open file:$!";
while ($line = <STDIN>)
{
while ($line =~ s/(\w+)(.*)/$2/)
{
$word = $1;
$wordHash{$word }++;
}
}
while (($word, $count) = each(%wordHash) )
{
$wordHash[$i] = "$word\t$count" ;
$i++;
print ("$word\n");
}
close(FILEHANDL E);
Comment