my ($sql_var_hr); $$sql_var_hr{col_name} = 'column_name'; my $sql = get_sql($sql_han, $sql_var_hr); sub get_sql { my ($file_han, $vars) = @_; #vars is a hashref containing any switch variables for the select my ($iline, $sql); print "vars: $$vars{col_name}\n"; while ($iline = ) { if ($iline =~ /^#/) { next; } else { $sql = $sql.$iline; } } print "pre_eval: $sql\n"; eval{$sql}; print "post_eval: $sql\n"; return $sql; } #the following are just attempts __DATA__ select $vars{col_name} from schema.table select $$vars{col_name} from schema.table select ${$var{col_name}} from schema.table