in reply to Re: Changing parameters
in thread Changing parameters

Hi,

Thanks for the reply.

Is there another way of changing both the values of i and j without knowing what their current values are?

Your suggestion above does work, but it requires knowing what the current values are of i inorder to change it from 2 to 4.

Thank you.

Replies are listed 'Best First'.
Re^3: Changing parameters
by fglock (Vicar) on Nov 29, 2004 at 19:28 UTC

    How about:

    perl -pi.bak -e 's!\$i = .*?;!\$i = 4;!' parameter.ph
      Thank you fglock
Re^3: Changing parameters
by Thilosophy (Curate) on Nov 30, 2004 at 03:15 UTC
    You could just append new values to the file.
    echo '$i = 987;' >> parameter.ph
    That will override the old values.

    If you do this often, and do not want the file to grow every time, save the original file and output to a new one.

    cp defaults.ph parameter.ph; echo '$i = 987;' >> parameter.ph