in reply to Update config file parameters

Hello pavan.gup, and welcome to the Monastery!

The Tie::File module makes this sort of task even easier. Don’t worry, you don’t have to install it — it’s a core module, so if you have Perl, you already have Tie::File:

#! perl use strict; use warnings; use Tie::File; my $filename = 'config.txt'; tie my @array, 'Tie::File', $filename or die "Cannot tie file '$filename': $!"; for my $line (@array) { my @fields = split /=/, $line; if ($fields[0] eq 'IPADDR') { $fields[1] = '1.2.3.4'; $line = join '=', @fields; last; } } untie @array;

— and the configuration file has been updated!

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,