foreach $a(@arr) { if $a is occurring more than two times in text then print "$a"; }