Something I'm messing with today and can't get right. I've presented
a simplified version of what I'd like to do. It amounts to setting
the strings inside a s/some_re/some_rep/ type action.
I can get it to work fine if both elements are simple and don't
involve grouping and back reference. But grouping and back reference
would make my script (the real one ) considerably more versatile.
Examples:
cat rein.pl
#!/usr/local/bin/perl -w
$strp_re = shift;
$rein_str = shift;
while(<>){
chomp;
$pre_out = $_;
($out = $pre_out) =~ s/$strp_re/$rein_str/;
print "$out\n";
}
echo something|./rein.pl thing body
somebody
======================
So far so good... but introduce back reference and it fails:
Example:
echo something|./rein.pl '(some)(thing)' '\1body'
\1body
or
echo something|./rein.pl '(some)(thing)' '\$1body'
\$1body
or
echo something|./rein.pl '(some)(thing)' \$1body
$1body
Is there some way to do this?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]