my %config_settings = ( CONFIG_NET => 'y', CONFIG_HOTPLUG => 'y', # whatever else you want to set ) open(KERNEL_CONFIG, '<', '/usr/src/linux2.4/.config'); open(NEW_CONFIG, '>', '/usr/src/linux2.4/.config.new'); while my $config_line () { $config_line =~ /([A-Z0-9_])/; $config_line = $1 . '=' . $config_settings{$1} . "\n" if exists $config_settings{$1}; print NEW_CONFIG $config_line; } close KERNEL_CONFIG;