I have quite a bit of personal distaste for Config::General but it might be what the doctor ordered in this case. You may have to adjust and I'm not sure if there's a setting to retain =s on the serialized config.

use Config::General; my $config = Config::General->new(-String => [ <DATA> ]); my %data = $config->getall(); $data{be_address} = "192.168.106.55"; my $new_config = Config::General->new(\%data); print "Original:\n", $config->save_string(); print "\nNew:\n", $new_config->save_string(); __DATA__ be_address = remote-be-address be_port = 9000 svs_port = 8733 log = log.txt verbose = 10 screen_print = true fe_id = 1 encryption_key = default_encrypt fe_id_last = 1 mtu = 45K cpu_throt = 100 bandwidth_throt = 100 system_tray_icon_enable = true email_notification_level = 10 web_access_enable = true sync_enable = true software_settings_interval = true min_space_for_dist = 30M

In reply to Re: how to search and replace some text in a .conf file by Your Mother
in thread how to search and replace some text in a .conf file by koti688

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.