On Wednesday 07 November 2007, [EMAIL PROTECTED] wrote: > On Nov 7, 5:43 pm, [EMAIL PROTECTED] (Charlie > Farinella) wrote:
> > 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 '<% %>' > 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 I am using bash, I should have made that clear. > perl -w -i -p -e "s/testtext/<% \\$bURL %>/g" test.html This did not work. > perl -w -i -p -e "s/testtext/'<% \$bURL %>'/eg" test.html This did! :-) > > perl -w -i -p -e 's/testtext/<% \$bURL %>/g' test.html This one worked as well, thank you. I haven't tried all the rest, but I will later, thanks to all, you've been very helpful. :-) > perl -w -i -p -e "s'testtext'<% \$bURL %>'g" test.html -- ------------------------------------------------------------------------ Charles Farinella Appropriate Solutions, Inc. (www.AppropriateSolutions.com) [EMAIL PROTECTED] voice: 603.924.6079 fax: 603.924.8668 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/