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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -