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 |