On Nov 7, 5:43 pm, [EMAIL PROTECTED] (Charlie
Farinella) wrote:
> Hi,
>
> I'm trying to substitute a string with a Mason variable in a bunch of
> files and not having any luck.  For instance I want to change the
> string 'testtext' to '<% $bURL %>' in a file:
>
> perl -w -i -p -e "s/testtext/'<% \$bURL %>'/g" test.html
>
> ..substitutes '<%  %>'
>
> I've tried quotes, double quotes, escape characters in various
> configurations, with no luck.
>
>  perl -e "print '<% \$bURL %>'"
>
> prints what I expect, so I'm lost as to what I need to write for the
> substitution.

Your problem here could well be that your command line shell is
consuming the \ before the $ so there's no \ in the Perl program you
are executing

(What command shell are you using?)

The RHS of s/// is a double-quotish string context you Perl thinks you
are trying to interpolate the perl variable $bURL. You need to protect
the $ twice. There are numerous ways to do this.

Assuming a Bourne-like shell any of the following should work

perl -w -i -p -e "s/testtext/<% \\$bURL %>/g" test.html

perl -w -i -p -e "s/testtext/'<% \$bURL %>'/eg" test.html

perl -w -i -p -e 's/testtext/<% \$bURL %>/g' test.html

perl -w -i -p -e "s'testtext'<% \$bURL %>'g" test.html



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to