mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-11 03:25:54 +02:00
general-functions.pl: Add function to get full country name.
This function will return the full name a country specified by it's country shortcut. It also will provide some additional names which are not handled by the perl locale module but are parts of ISO 3166.
This commit is contained in:
@@ -17,6 +17,7 @@ package General;
|
||||
use strict;
|
||||
use Socket;
|
||||
use IO::Socket;
|
||||
use Locale::Country;
|
||||
use Net::SSLeay;
|
||||
use Net::IPv4Addr qw(:all);
|
||||
$|=1; # line buffering
|
||||
@@ -1123,4 +1124,30 @@ sub get_red_interface() {
|
||||
return $interface;
|
||||
}
|
||||
|
||||
# Function to get the county name by a given country code.
|
||||
sub get_full_country_name($) {
|
||||
my ($input) = @_;
|
||||
my $name;
|
||||
|
||||
# Remove whitespaces.
|
||||
chomp($input);
|
||||
|
||||
# Convert input into lower case format.
|
||||
my $code = lc($input);
|
||||
|
||||
# Handle country codes which are not in the list.
|
||||
if ($code eq "a1") { $name = "Anonymous Proxy" }
|
||||
elsif ($code eq "a2") { $name = "Satellite Provider" }
|
||||
elsif ($code eq "o1") { $name = "Other Country" }
|
||||
elsif ($code eq "ap") { $name = "Asia/Pacific Region" }
|
||||
elsif ($code eq "eu") { $name = "Europe" }
|
||||
elsif ($code eq "yu") { $name = "Yugoslavia" }
|
||||
else {
|
||||
# Use perl built-in module to get the country code.
|
||||
$name = &Locale::Country::code2country($code);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user