my %file1; while () { next unless (/.:./); # maybe warnings aren't needed here chomp; my ($key,$val) = split( /:/, $_, 2 ); if ( $key =~ /^\s*$/ ) { warn "$inf1:$.:Empty key field\n"; next; } if ( exists( $file1{$key} )) { warn "$inf1:$.:Duplicate key string\n"; next; # might want to say more about that } # might want to check $val too... # get here if everything's okay: $file1{$key} = $val; } close IN1;