use Hash::Util qw(lock_hash); my %settings; foreach my $key (qw(input output pattern replacement)) { print "$key = "; my $setting = ; chomp $setting; $settings{$key}=$setting; } lock_hash %settings;