regex - Combining a Variable and Regular Expression in Perl -
i have code: $temp =~ s/\#name\#/$customername/g; where replacing #name# value in $customername using regex. want append variable onto end of name . so want like: $temp =~ s/\#name . $appendvalue\#/$customername/g; so be: $temp =~ s/\#name_1\#/$customername/g; would work or there proper way handle this? test cases: hello #name# this intended #name# the pattern interpolates variables, no concatenation operator needed: $temp =~ s/#name$appendvalue#/$customername/g; you might need protect special characters in variable, though, use \q...\e : $temp =~ s/#name\q$appendvalue\e#/$customername/g; # not special in regex, no backslash needed (but doesn't hurt).