From your OP, I would assume you want variable file names. If you want to have variable file contents (without the need of disk I/O), the possibility depends on the external program. If it can use STDIN/STDOUT, then you should probably look into IPC::Open2.
Re: external program variables
Replies are listed 'Best First'.