Thx, pg^^.
Just like you said, I gave up on trying to improve the performance of my program, but instead, I checked whether the file that I stored in the variable exists or not by using "-e $filename".
What you wrote was really helpful.
Thank you again.
snam