#!/usr/bin/perl use warnings; use strict; my %words; while (defined (my $line = )) { ++$words{lc $_} for $line =~ /(\w+)/g; } printf "There are %d occurences of '%s'\n", $words{lc $_}, $_ for grep {exists $words{$_} && $words{$_} > 1} qw(text i); __DATA__ hi monks Happy new year to everyone i have any array with me say @arr which contains number of words(may contain spaces) and i also have a text (in array) which contains a text of say 1000 lines. i need to do #### There are 2 occurences of 'text' There are 3 occurences of 'i'