s_gaurav1091 has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks , I am using a command to substitute the contents of my file my file contains a line site.type=standby and i want to change that line to site.type=production.I am getting errors in the code.I am wriiting the code as well as the error for your refrence.Please suggest something
perl -pi -e 's/site.type=standby/site.type=production/gei ' /usr/local +/jboss/conf/environment.properties
It is giving an error that can't modify concatenation (.) or string in scalar assignment at -e line 1, near "production }"

Replies are listed 'Best First'.
Re: substitution using perl -pi -e
by Corion (Patriarch) on Nov 08, 2005 at 08:32 UTC

    Why are you using the /e switch? This makes Perl think that you want to see the "replacement" part of s/// as a Perl expression. You likely want:

    perl -pi.bak -e 's/site.type=standby/site.type=production/gi' /usr/loc +al/jboss/conf/environment.properties
Re: substitution using perl -pi -e
by b10m (Vicar) on Nov 08, 2005 at 10:59 UTC

    Or just "sed -i 's/site.type=standby/site.type=production/gi' /.../environment.properties" ;-)

    --
    b10m

    All code is usually tested, but rarely trusted.
Re: substitution using perl -pi -e
by blazar (Canon) on Nov 08, 2005 at 10:37 UTC

    Indeed /e executes in the replacement part of the s/// operator. Do you happen to know that

    site.type=production;

    is valid Perl (5, that is!) code? How so?!?

    Incidentally you may use

    s/(?<=site.type=)standby/production/gi

    instead.

A reply falls below the community's threshold of quality. You may see it by logging in.