in reply to how to search and replace some text in a .conf file
open inFILE, "svs.conf" or die $!; @lines = <inFILE>; close inFILE; open outFILE, ">svs.conf" or die $!; for $i (0 .. $#lines) { ($param, $value) = split(/\=/, $lines[$i]); if ($param eq 'be_address') { $value = $new_value; print outFILE $param." = ".$value; } else { print outFILE $lines[$i]; } } close outFILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to search and replace some text in a .conf file
by chromatic (Archbishop) on May 18, 2009 at 21:12 UTC | |
|
Re^2: how to search and replace some text in a .conf file
by koti688 (Sexton) on May 18, 2009 at 18:28 UTC | |
by Corion (Patriarch) on May 18, 2009 at 18:39 UTC | |
by GrandFather (Saint) on May 18, 2009 at 21:13 UTC | |
by punch_card_don (Curate) on May 18, 2009 at 18:45 UTC |