regex - Perl: How to replace a variable by its value -


suppose, if table has column called test , inside test have written row "dear $name, hello" $name variable. need select row i'm doing

my $test = $dbh->prepare( "select test testing")  

in script have assigned $name="joe" . now, need replace $name variable variable name assigned in script (i.e joe). tried printing $test. prints "dear $name, hello" how can this.

you can try this:

use strict;  $name = "joe"; $test = 'dear $name, hello';  $test =~ s/\$name/$name/ ;  print $test; 

output:

dear joe, hello   

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -