Substitution Tags(替换标签)
% $cd_count = 207; # this is embedded Perl You have <% $cd_count %> CDs.
Escaping substitutions(转义替换), 两个字符 h(html),u(URL),n(不转义)
<textarea name="foo"><% $foo_data | h %></textarea>
Homepage: <a href="redirect?url=<% $homepage | u %>">
Embedded Perl: % Lines and <%perl> Blocks (嵌入perl)
% foreach my $person (@people) { Name: <% $person->{name} %> Age: <% $person->{age} %> Height: <% $person->{height} %> Weight: <% $person->{weight} %> % }
如果有多行则可以用<%perl> </%perl>
If you have more than a few lines of Perl code in a row, however, it is probably best to use a Perl block instead
<%perl> my @words = $sentence =~ /(S+)/g; my @small_words = grep { length $_ <= 3 } @words; my @big_words = grep { length $_ > 3 } @words; </%perl>
Calling Other Components: <& &> Tags 调用其它组件
调用组件
<& /path/to/menu &> <& $component &>
<& menu, width => 640, admin => 1 &>
可以用+或者()表示为表达式运行
<& ( component_path_returner( ) ) &> <& +component_path_returner( ) &>
<%init> blocks , 初始化块
It is currently <% $temp %> degrees. <%init> my ($temp) = $dbh->selectrow_array("SELECT temperature FROM current_weather"); </%init>
<%args>
<%args> $color #是必需要传入数据的 $size => 20 @items => ( 1, 2, 'something else' ) %pairs => ( key1 => 1, key2 => 'value' ) </%args>
获取提交表单值 $ARGS{'submit.x'}
% foreach (sort %ARGS) { <% $_ %> % } % foreach (sort @_) { <% $_ %> % }
可通过http传递获取参数