in reply to building Drop down menu - from a flat file

I just performed the very same task for a CGI/DNS Dig tool I've been working on. The solution has been presented in one form or fashion already, but I thought I'd toss my hat in since I've combined it with the use of HTML::Template (kick ass for tables and loops).

The first section is an example of the data in the flat file. The next section of code sends the AoH to the template object. The third section is what creates the AoH, and the final section is the snippet from the template file.

-fp
# Flat file ac 193.0.0.193 Ascension Island as 128.250.1.21 American Samoa be 192.36.125.2 Belgium biz 209.173.53.162 US BIZ
------------------------------------------------------------
# send data to template my @root_loop = &get_roots; my $template = HTML::Template->new(filename => 'Digbeta/digauthform.tm +pl', die_on_bad_params => 0); $template->param(root_loop => @root_loop); print $template->output;
------------------------------------------------------------
# create Array of Hashes sub get_roots { my @root_loop; open(ROOTS, "roots3"); foreach (<ROOTS>) { chomp; my ($code, $ip, $country) = /(.*)\t(.*)\t(.*)/; my %roots_row = ( code => $code, ip_addy => $ip, country => $country ); push(@root_loop, \%roots_row); } return \@root_loop; }
------------------------------------------------------------
# HTML Template <select NAME="server"> <option SELECTED VALUE="Default">Default (as per Query Type) <TMPL_IF root_loop> <TMPL_LOOP NAME="root_loop"> <option VALUE="<TMPL_VAR NAME="code">"><TMPL_VAR NAME="code"> - < +TMPL_VAR NAME="country"> </TMPL_LOOP> </TMPL_IF> </select>