in reply to How to search string in all files in directory

this sounds quite like a task for App::Ack unless you want to reinvent the wheel

$ cpan App::Ack

and write some glue or just use the supplied ack script