in reply to
search for a pattern in file without opening the file
I'm not saying this is the answer to your question, but perhaps you should have a look at File::Grep.
File::Grep mimics the functionality of the grep function in perl, but applying it to files instead of a list. This is similar in nature to the UNIX grep command, but more powerful as the pattern can be any legal perl function.
For those who were quick with the tedious wisecracks -- perhaps the OP meant that he didn't want to have to do the file open in his own code.