Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么perl中的数组值没有使用html模板列在下拉列表中?_Perl - Fatal编程技术网

为什么perl中的数组值没有使用html模板列在下拉列表中?

为什么perl中的数组值没有使用html模板列在下拉列表中?,perl,Perl,我的perl cgi页面下拉菜单不存在;t列出值。我的cgi脚本 use HTML::Template;use CGI; use CGI::Carp qw(fatalsToBrowser); my $template = HTML::Template->new(filename => 'test.tmpl'); @count = ("abc,xyz,123,test"); print $cgi->start_form( -name

我的perl cgi页面下拉菜单不存在;t列出值。我的cgi脚本

use HTML::Template;use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $template = HTML::Template->new(filename => 'test.tmpl');
@count = ("abc,xyz,123,test");
print $cgi->start_form(
                        -name => 'mainpage',
                        -method => 'POST',
                        );


$template->param( COUNT => \@count);
print $template->output();
我的test.tmpl

<div class="row ">
            <div class="col-lg-8 col-lg-offset-2">
                                <div class="dropdown">
                                <div class="input-field col s6">
                                <input name="count" id="countid" type="text" class="validate">
                                <label for="count">count</label>
    <select>
        <TMPL_LOOP NAME="COUNT">
        <option value="<TMPL_VAR NAME=VALUE>"><TMPL_VAR NAME=NAME></option>
        </TMPL_LOOP>
    </select>                                
</div>

in the drop down menu, I am expecting below values. Please suggest if I need to make any change on above code on cgi or html template
abc
xyz
123
test
下面呈现的html页面

<div class="row ">
            <div class="col-lg-8 col-lg-offset-2">
                <div class="dropdown">
            <div class="input-field col s6">
                <input name="count" id="countstate" type="text" class="validate">
                            <label for="count">count</label>
<select>

<option value="1">count1</option>

<option value="2">count2</option>

<option value="3">count3</option>

</select>                                

数组包含一个元素:字符串abc,xyz,123,test。如果希望这些元素中的每一个都是独立的元素,则需要以不同的方式创建阵列:

@count = ('abc', 'xyz', 123, 'test');
@count = qw(abc xyz 123 test);
更新:好的,在阅读了的文档之后,看起来您实际上想要一个:


但是,我无法从您的问题中判断哪一个应该是标签,哪一个应该是值,因此我将把它作为练习留给您完成。

您好,谢谢您的回答。我正在寻找只在下拉菜单abc xyz 123测试中列出的值。查看页面源这些值,但是在cgi页面下拉选项卡中显示为空。谢谢,我不明白你在说什么。HTML源代码正确,但呈现的输出不正确?是。html输出是正确的。cgi页面不会在下拉菜单中显示这些值。我正在使用div方法下拉发布我的问题。谢谢你好的。。。那么页面显示的是什么呢?你能把你的问题包含在模板引擎呈现的HTML源代码中吗?HTML看起来不错。那么你在浏览器中看到了什么呢?此时附加一个屏幕截图可能会有所帮助。看起来你很可能在这一点上有一个CSS问题。。。
@count = ('abc', 'xyz', 123, 'test');
@count = qw(abc xyz 123 test);
$count = [
    { name => '???', value => 'abc' },
    { name => '???', value => 'xyz' },
    { name => '???', value => '123' },
    { name => '???', value => 'test' },
];

$template->param(COUNT => $count);
$template->param(COUNT => [{...}, {...}, {...}, ...]);  # same thing