use warnings; use strict; use HTML::EasyTags; opendir my $LogDirScan, "."; my @logfiles = readdir $LogDirScan; closedir $LogDirScan; my @countries; my @single_countries; if (@logfiles) { foreach my $filename (@logfiles) { $filename =~ s/\.txt/ /; push (@countries, "$filename"); } } foreach my $country_data (@countries) { my @splitted_country_name = split (/\-/, $country_data); push @single_countries, $splitted_country_name[0]; } my %saw; my @unique_countries = grep (!$saw{$_}++, @single_countries); my $html = HTML::EasyTags->new(); print $html->start_html (); print $html->table_start (); foreach my $final_country (@unique_countries) { next if ! length $final_country; my $no_line_country = $final_country; my @single_states; # Countries like EL_Salvador or Costa_Rica need to have underscores removed $no_line_country =~ s/_+/ /g; foreach my $Country_File (@countries) { my @splitted_country_name = split (/\-/, $Country_File); next if ! $#splitted_country_name; next if $final_country !~ /$splitted_country_name[0]/; my $final_state = $splitted_country_name[1]; my $no_line_state = $final_state; $no_line_state =~ s/_/ /g; my $State_Row = $html->tr ($html->td ($no_line_state)); push (@single_states, $State_Row); } print $html->tr ($html->td ($no_line_country)); print "@single_states"; } print $html->table_end (); print $html->end_html ();