One option is the Config::Tiny module.
Its pretty easy to use. But note that it does not preserve the order of params when you write the file back out.
#!/usr/bin/perl -w use strict; use Config::Tiny; use Data::Dumper; my $Config = Config::Tiny->read( 'configtinytest.ini' ); # "_" is the default section (the one with no name) $Config->{'_'}->{'be_address'} = '192.168.106.55'; print Dumper ($Config); $Config->write( 'configtinytest2.ini' ); __END__ configtinytest.ini: ------------------- 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 configtinytest2.ini: -------------- bandwidth_throt=100 be_address=192.168.106.55 be_port=9000 cpu_throt=100 email_notification_level=10 encryption_key=default_encrypt fe_id=1 fe_id_last=1 log=log.txt min_space_for_dist=30M mtu=45K screen_print=true software_settings_interval=true svs_port=8733 sync_enable=true system_tray_icon_enable=true verbose=10 web_access_enable=true

In reply to Re: how to search and replace some text in a .conf file by Marshall
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.