Greetings all,
I am not entirely sure I understand the problem but here are my thoughts on how to get (according to my understanding) the desired results.
why not create the list once and assign it to a string, then use regex string replacement for your various values;
my $dd_country_str;
unless(open(FILE, "<countries.txt")){
die "cannot read file";
}else{
$dd_country_str .= qq*<select name="countries">\n*;
while(<FILE>){
if(/(.*):(.*)/i){
$dd_country_str .= qq*<option value="$1">$2</option>\n*;
}
}
$dd_country_str .= qq*</select>\n*;
close(FILE);
}
###now call the dd_str you just built;
my $first_dropdown = $dd_country_str;
$first_dropdown =~ s/(value="$country_alias_you_want_selected")/$1 sel
+ected="selected"/g; ###XHTML compliant
print $first_dropdown;
.
.
.
Is that what you are looking for? It seemed from your original post you were going to be using the same list of countries each time, so I just created the dropdown list in a string and reused that each time.
just a thought.
Also you do not need to specify a name for each option within your select. The name of the select is what will be passed and assigned the value of whatever option is selected.
-injunjoel
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.