2015-02-09 91 views
0

最近我正在調試一段代碼,發現模板中模板工具箱用法中的下列用法。perl語法來訪問cgi腳本中的常量變量

#Constants.pm 
# Bugzilla version 
use constant BUGZILLA_VERSION => "4.0.11"; 


#template file index.html.tmpl 
[% PROCESS global/header.html.tmpl 
    header_addl_info = "version $constants.BUGZILLA_VERSION" 
    style_urls = [ 'skins/standard/index.css' ] 
%] 

#index.cgi 
use Bugzilla::Constants; 
....... 

print "buzilla version : $constants.BUGZILLA_VERSION <br/>"; 

當我使用主CGI腳本相同的語法,給錯誤500

回答

1
print "buzilla version : ".Bugzilla::Constants::BUGZILLA_VERSION." <br/>"; 
0

''可能意味着在Template :: Toolkit中有所不同。

在Perl中你只需要使用BUGZILLA_VERSION:

$ perl -E 'use constant BUGZILLA_VERSION=>"4.0.11"; say BUGZILLA_VERSION' 
4.0.11 
$