diff --git a/createdatabase.PL b/createdatabase.PL index 25cba44..a62e7e1 100755 --- a/createdatabase.PL +++ b/createdatabase.PL @@ -4760,21 +4760,22 @@ sub country { my($file, $state) = @_; + # Ensure the file argument is provided die if(!defined($file)); - if($file =~ /north-america/) { - return 'US' - } - if($file =~ /australia/) { - return 'Australia' - } + # Check for file patterns and return corresponding country + return 'US' if $file =~ /north-america/; + return 'Australia' if $file =~ /australia/; - die if(!defined($state)); + # Ensure the state argument is provided if needed + die "State argument is missing" if not defined $state; - if($file =~ /europe/) { - if(($state eq 'Georgia') || ($state eq 'GA') || (uc($state) eq 'DE') || ($state eq 'VI')) { - return $state - } + # Handle European cases with specific state codes + if ($file =~ /europe/) { + my %valid_states = map { $_ => 1 } ('Georgia', 'GA', 'DE', 'VI'); + return $state if $valid_states{$state} || $valid_states{uc($state)}; } - die "$file/$state" + + # Default case: Raise error with both file and state information + die "$file/$state"; }