You need a double evaluation there. The first /e puts the contents of $str_regex into the replacement, and the second /e evaluates the contents as Perl code. Notice I double quote around $str_regex: one to quote it, and one for the Perl code I'll evaluate later.
$old_db = "emdb1"; $new_db = "kuku"; $string = "AUTHORIZATION,libctl62-m.sl,CONTROLM,emdb1,b02ed6600206 +ca161d165355c67b72073b6123d6838f1f68203b78cb9c4c63c9,emdb2,,;" ; $str_regexp = '"$1$2$3$new_db,"' ; $string =~ s/([^,]*,)([^,]*,)([^,]*,)([^,]*,)/$str_regexp/ee; print "$string\n";
Also, the right hand side is just a double quoted string. It's not a regexp in any way.
Lastly, if you're manipulating anything more complex regularly, you might want to use one of the comma separated value modules on CPAN rather than doing it yourself.
Good luck :)
In reply to Re: use qr// variable in right side of s/// operator
by brian_d_foy
in thread use qr// variable in right side of s/// operator
by psimonovsk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |