in reply to Use of grep and foreach
It sounds like you're just staring out. You might want to pick up a copy of Learning Perl or Programming Perl these are excellent books published by O'Reilly. If you don't have your books handy there is plently of on line documentation. You also have documentation on you machine. They this
perldoc -h
perldoc -f grep
Good luck.