in reply to Update config file parameters

Assuming order is not important and there are no duplicates I would read the file into a hash and then change the values of interest:

use strict; use warnings; my %config = map { /(.*)=(.*)/ } <DATA>; $config{'IPADDR'} = '1.2.3.4'; print "$_=$config{$_}\n" for keys %config; __DATA__ DEVICE=eth0 ONBOOT=yes BOOTPROTO=static TYPE=Ethernet IPADDR=10.9.0.200 NETMASK=255.255.0.0 GATEWAY=10.9.1.254

Replies are listed 'Best First'.
Re^2: Update config file parameters
by GotToBTru (Prior) on Jan 05, 2016 at 14:58 UTC

    This has slight superiority over the current best idea in that, if the tag does not yet exist, this will create it.

    But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)