#!/usr/bin/perl

	open (LOGFILE, "mytext.txt") or die "I couldn't open log.txt: $!";
    # We'll discuss the "or die" in a moment.
	print "before reading...\n";
	%hash=();
    for $line (<LOGFILE>)
    {    	
        #print $line;
		@words=split(/\s+/,$line);
		print "line is '$line'\n";
		for $word (@words)
		{
			print "word is '$word'\n";
			if ($word =~ /^[a-z]*[a-z]$/)
			{
				print "\n====='$word' will be added into hash=====\n";
				$hash{"$word"} ++;		
			}
		}
    }
    close LOGFILE;
	#print keys %hash;
	$number = keys %hash;
	print "================number=$number=====================\n";
	my $counter=0;
	while (my ($key,$value)= each(%hash))
	{
		print "key '$key' occurs $value\n";
		$counter++;
	}
	print "counter=$counter\n";
	


