Xaqte thanks for the welcome and for the help. I'm almost there. I made the changes you suggested, but had to slightly modify it because the script wouldn't run at all. Now it's function almost how it should. At the end of script execution I get the following...
Use of uninitialized value...