use HTML::Template; my $tmpl = q{ }; my @options = (); for (0..5) { push @options, { VALUE => $_, SELECTED => $_ == 3 ? 'selected' : '', TEXT => { 0 => ' any', 1 => ' one day', 2 => ' two days', 3 => ' three days', 4 => ' four days', 5 => ' one week', }->{$_}, }; } my $t = HTML::Template->new(scalarref => \$tmpl); $t->param(OPTIONS => \@options); print $t->output;