use English '-no_match_vars'; open $input_fh, '<', $input_fn or die 'Could not open file: ', $OS_ERROR; my $hash; while ( my $line = <$input_fh> ) { chomp $line; last if ! $line; # Split line with a limit of two my ( $word1 , $word2 ) = split /:/, $line, 2; $hash->{$word1} = $word2; } close $input_fh or die 'Could not close file: $OS_ERROR';