3 # demo script for Locale::SubCountry
6 use Locale::SubCountry;
9 # list the country name
10 # if any subcountries, list each code and full name on a new line
12 my $world = new Locale::SubCountry::World;
13 my @all_countries = $world->all_full_names;
16 foreach my $country ( sort @all_countries )
18 print "\n\n$country\n";
19 my $current_country = new Locale::SubCountry($country);
21 # Are there any sub countires?
22 if ( $current_country->has_sub_countries )
24 # Get a hash, key is sub country code, value is full anme, such as
25 # SA => 'South Australia', VIC => 'Victoria' ...
26 my %sub_countries_keyed_by_code = $current_country->code_full_name_hash;
27 foreach my $code ( sort keys %sub_countries_keyed_by_code )
29 printf("%-3s : %s\n",$code,$sub_countries_keyed_by_code{$code});