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
Post a Comment