in reply to Storing a variable in a file and processing within the script

As an aside, you may want to look at Querylet, which implements the "run SQL, create Excel" workflow.

If you still want to roll your own, have a look at various templating engines, Interpolation or this very, very basic regex:

my %variables= ( table_name => 'EMPLOYEE', # setting a table name ); ... $sql=~ s!\$(\w+)!$variables{ $1 } || "\$$1" !ge; print $sql;