in reply to
Use of grep and foreach
monaLisa, I've already downvoted one of your previous questions. Even if nobody cares about XP, here, ( ;-) ) and I'm sure you do the same, receiving tons of --s could discourage you, and could make you fail to
perceive and obtain the benefits this site can give to you. So, here some advices on how to ask a question, in order to obtain the maximus of help and achievement: How to RTFM.
For what concerns your specific problem, you'll find useful informations in
perlfunc, perlop and perlre.