in reply to reading from directory

IMO you should be using File::Find. That will traverse a whole tree for you.
use File::Find; find sub { if(-f) { system("grep 'theInfoLookingFor' $_ >$_.out"); } }, $rootdir;