in reply to search for a pattern in file without opening the file
That is rather similar to the problem I have with a sealed black box. I want to know what is in it, but I'm not allowed to open it. I do know the address information on the outside of the box and how large it is - stuff like that, but I've no idea what is inside it. Perhaps if you solve your problem (using a clairvoyant perhaps?) you could tell me how you did it and I can use the same technique for my problem?
Actually, solve that problem and we can sell the solution to kids who want to find out what is in their birthday presents!
In the mean time you may be interested in reading Perl's grep documentation. It is not a *nix grep (which does "open the files" btw).
DWIM is Perl's answer to Gödel