in reply to REGEX:getting the count of occerence

Why not show us what you are actually using rather than making us guess?

In general if you need to check if 'somethings' exist in a (large) 'something' else in Perl you tend to us a hash which is populated from the 'something' and keyed by potential 'somethings'. For example you could:

#!/usr/bin/perl use warnings; use strict; my %words; while (defined (my $line = <DATA>)) { ++$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 c +ontain spaces) and i also have a text (in array) which contains a text of say + 1000 lines. i need to do

which prints:

There are 2 occurences of 'text' There are 3 occurences of 'i'
True laziness is hard work