in reply to Search a text in a file

checking if $text is there( by using =~)
if $text is supposed to be a regex, you won't have another choice. but if it's only text why don't you use the index()-function or the 'eq' opreator for that?

anything else would depend on your text file, i'd say. do you have sorted lines or something like that? then you ca do a binary search which will be much quicker.

update: and if you have grep available on your system i'd go for that