Snafu, thanks a lot for your help, I think you are right on track. The only problem is that when I run the code I get an error saying that there are not enough arguments for grep on the line where grep is used. I have very limited knowledge of Perl and would appreciate any suggestions you have to fix this. All of your assumptions you made were correct.
Thanks