http://qs1969.pair.com?node_id=11136867


in reply to Re^3: Automating execution of shell scripts
in thread Automating execution of shell scripts

Sorry I forgot to mention this was only a snippet of the whole program, and it wasn't exactly accurate to what I had in actual program.
I just wanted to illustrate what the direction in which I was headed for solving this.
Sorry also that I couldn't just paste the whole code.
Anyway in my actual program it turned out that the issue was the scope of the $dir variable in my subroutine as far as I can tell.
The program works correctly now.
I guess it would be better (also faster?) if it is done in the main program and not in a subroutine, but it was easier for me to follow what I am doing by writing subroutines. I am also not sure how to do what you mention.