opendir LOGDIR, "COUNTRIES";
@logfiles = readdir (LOGDIR);
closedir (LOGDIR);
if (@logfiles) {
foreach $filename (@logfiles) {
$filename =~ s/.txt/ /;
push (@countries, "$filename");
}
}
foreach $country_data (@countries) {
@splitted_country_name = split(/\-/,$country_data );
push (@single_countries, "$splitted_country_name[0]");
}
undef %saw;
@unique_countries = grep(!$saw{$_}++, @single_countries);
print"
"
foreach $final_country (@unique_countries) {
#### Countries like EL_Salvador or Costa_Rica need
#### to have underscores removed
$no_line_country = "$final_country";
$no_line_country =~ s/_/ /g;
foreach $Country_File (@countries) {
@splitted_country_name = split(/\-/,$Country_File );
if($final_country =~ /$splitted_country_name[0]/){#1
$final_state = "$splitted_country_name[1]";
$no_line_state = "$final_state";
$no_line_state =~ s/_/ /g;
$State_Row ="$no_line_state |
";
push (@single_states, "$State_Row");
}
}
print"$no_line_country |
"
print "@single_states";
}
print"
"