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>

In reply to Re: building Drop down menu - from a flat file by fuzzyping
in thread building Drop down menu - from a flat file by data67

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.