perl - Variable Replacement using Regex -
i want replace variable in file(temp.txt) in perl.
temp.txt
hi $test. how you??
now want replace variable $test
. code tried below:
open $filename, "<", temp.txt or die $!; while (<$filename>) { s/$test/'abc'/g; print; }
it not working. can tell me doing wrong?
you need escape $
because perl thinks variable:
use warnings; use strict; while (<data>) { s/\$test/'abc'/g; print; } __data__ hi $test. how you??
Comments
Post a Comment