Re: Edit a config file using perl cgi script

2009-07-09 Thread Randal L. Schwartz
> "Eric" == Eric Veith writes: Eric> sudo perl -e 'open($fh, "<", "/tmp/foo"); @f = <$fh>; close($fh); open($fh, Eric> ">", "/tmp/foo"); foreach(@f) { s/^(Key1=).*/$1NewValue1/; print $fh $_; } Eric> close($fh);' Eric> As always, TIMTOWTDI. Much easier way is in-place editing: perl -pi.ba

Re: Edit a config file using perl cgi script

2009-07-09 Thread Eric Veith
x27;ll probably know that already. :-) -- Eric Alpesh Naik wrote on 07/09/2009 12:23:54 PM: > From: > > Alpesh Naik > > To: > > Eric Veith/Germany/i...@ibmde > > Date: > > 07/09/2009 12:23 PM > > Subject: > > Re: Edit a config file usi

Re: Edit a config file using perl cgi script

2009-07-09 Thread Eric Veith
sudo perl -e 'open($fh, "<", "/tmp/foo"); @f = <$fh>; close($fh); open($fh, ">", "/tmp/foo"); foreach(@f) { s/^(Key1=).*/$1NewValue1/; print $fh $_; } close($fh);' As always, TIMTOWTDI. HTH, -- Eric, Alpesh Naik wrote on 07/09/2009 11:34:43 AM: > From:> > > Alpesh Naik > > To: > >

Re: Edit a config file using perl cgi script

2009-07-09 Thread Jenn G.
On Thu, Jul 9, 2009 at 5:34 PM, Alpesh Naik wrote: > > For eg: below is what I have in the config file "configfile.cfg". > > Key1=OldValue1 > Key2=OldValue2 > > I want to search for "Key1" and change "OldValue1" to "NewValue1" Read the content into memory, search the key (i.e, use a regex) and rep