... $line =~ /^([^=]+)\s*=\s*(.*)/; #### while( <> ){ next if /^#/; #check for comment next unless /=/; #check if = present chomp; #remove newline split /\s*=\s*/, $_, 2; #split line to @_ $values{ $_[0] } = $_[1]; #assign to hash }