in reply to create environment variable at run time

Environment variables live in the %ENV hash. You can create them as you like, and the process and its children see that value.

$ENV{TESTDIR} = './t';

You can't set this value from one process and see it in some other process without some sort of IPC trick, though. If at all possible, you should try to set it before you run the script according to whatever your shell allows.

--
brian d foy <bdfoy@cpan.org>