tony@perlmonks.org has asked for the wisdom of the Perl Monks concerning the following question:
Hi Guys, I have a plain text file with a sql statement and want to put a variable name within it, which should be read by my perl script.
So for example: There is a a file called input.txt with the SQL content as below. Notice the $table_name intended to be processed within the script.
input.txt Text File content :my $sql; my $table_name = "EMPLOYEE"; # setting a table name. my $Inputfile = 'input.txt'; open my $filecontent, $inputfile or die "Could not open $inputfile +: $!"; while( my $readline = <$filecontent>) { print "$line \n"; $sql = $readline; executeSQL(); } close $$filecontent; }
If I execute the script, it reads the file but treats the $table_name as a string. How can I tell perl to treat it as a variable and assign the $table_name value declared at the start of the script to this value?
Thanks for any inputs on this..
|
|---|