-print "<table class='tbl'>";
-print "<tr><th style='width=5%;'><b>$Lang::tr{'flag'}</b></th>";
-print "<th style='width=5%;'><b>$Lang::tr{'countrycode'}</b></th>";
-print "<th style='width=40%; text-align:left;'><b>$Lang::tr{'country'}</b></th>";
-print "<th> </th>";
-print "<th style='width=5%;'><b>$Lang::tr{'flag'}</b></th>";
-print "<th style='width=5%;'><b>$Lang::tr{'countrycode'}</b></th>";
-print "<th style='width=40%; text-align:left;'><b>$Lang::tr{'country'}</b></th></tr>";
-
-@flaglist = <$flagdir/*>;
-
-undef @flaglistfiles;
-
-foreach (@flaglist)
-{
- if (!-d) { push(@flaglistfiles,substr($_,rindex($_,"/")+1)); }
-}
-my $col="";
-foreach $flag (@flaglistfiles)
-{
+
+print<<END;
+<table class='tbl'>
+ <tr>
+ <th style='width=5%'><b>$Lang::tr{'flag'}</b></th>
+ <th style='width=5%'><b>$Lang::tr{'countrycode'}</b></th>
+ <th style='width=40% text-align:left'><b>$Lang::tr{'country'}</b></th>
+ <th> </th>
+ <th style='width=5%'><b>$Lang::tr{'flag'}</b></th>
+ <th style='width=5%;'><b>$Lang::tr{'countrycode'}</b></th>
+ <th style='width=40% text-align:left;'><b>$Lang::tr{'country'}</b></th>
+ </tr>
+END
+
+# Get a list of all supported country codes.
+my @countries = Locale::Codes::Country::all_country_codes();
+
+# Loop through whole country list.
+foreach my $country (@countries) {