Now I realize what your program is for. You are using perl
to check syntax of tcl files. That's like using a Ferrari to
tow your Corvair. Just convert all your code to perl and you
won't have to do this code at all.
To check the syntax of perl code:
perl -c myperlcode