I have just seen your reply. To be honest, there are some large gaps in my knowledge of Perl and I did not know the importance of strict and warnings. I am now working on my script to address this and I will repost it when I have done so. I hope that you will give it ago again once I have done this.
Thank you very much.