in reply to Re: Re: $ variables in command line
in thread $ variables in command line
$1 is substituted with whatever was matched in a previous regex. To prevent interpolation, use single quotes. That doesn't solve the whole problem, however. Now we need to substitute the strings, including metacharacters, into s///. To interpolate, then substitute, I'll use an eval:$r = "$1 world";
A good general rule to follow is to use single quotes if you want the string as is, and use double quotes if you want interpolation. -Mark$s = '(hello)'; $r = '$1 world'; $_ = 'hello'; eval "s/$s/$r/"; print $_;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: $ variables in command line
by cruelmonk (Initiate) on Jun 26, 2002 at 22:09 UTC |