package MySample; sub build_dropdown { # build_dropdown( \$DataObject , 'key_function', 'text_function', 'Select A Header', 'preselectedValue' ); my @xml; if ( $_[3] ) { push @xml , qq{}; push @xml , qq{}; } foreach my $id ( $_[0]->{$_[1]}() ) { my $sel = ( $id == $_[4] ) ? ' selected' : ''; push @xml , ("'); } return join "\n" , @xml; }