in reply to editing options in a file

How about something like this?

my %config = ( CONFIG_PCI => 'y', CONFIG_BSD_PROCESS_ACCT => 'y', ); while (<>) { if ((my ($n,v) = split/=/) == 2) { if (my $new_value = $config{$n}) { print "$n=$new_value\n"; next; } } print; }

Replies are listed 'Best First'.
Re^2: editing options in a file
by dsheroh (Monsignor) on Jun 21, 2006 at 15:41 UTC
    Note that, with the config extract provided by OP,
    # CONFIG_HOTPLUG_PCI is not set
    doesn't match your split, which would prevent the value from being set if needed.