in reply to use qr// variable in right side of s/// operator
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 :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: use qr// variable in right side of s/// operator
by ikegami (Patriarch) on Feb 15, 2006 at 16:52 UTC | |
by brian_d_foy (Abbot) on Feb 15, 2006 at 20:17 UTC | |
by ikegami (Patriarch) on Feb 15, 2006 at 20:24 UTC |