use strict; use warnings; use diagnostics; use 5.010000; open('FILE','E:\Data.doc') or die $!; my $find; # the word to be searched print"What are you searching for ?"; chomp($find=); my $count=0; # It will count the word if it exists while(){ my $string = $_; my @temp = split(' ',$string); foreach my $loop(@temp){ $count++ if($loop =~ m/$find/i);} } print"\n$find occcured $count times in your file."