0
使用變量我有以下包:更新,並從包
package My::Content;
our $new = undef;
our $content = '<header>content-start'.$new.'content-end</header>';
1;
而且下面的腳本:
use My::Content;
use warnings;
use strict;
$My::Content:new = '++test++';
print $My::Content:content;
然而結果是「內容startcontent端」。正如我從這裏理解的那樣,包變量$content
在編譯時被設置,並且$ new值被取爲undef,而不管後面的變量更新。是否有可能在$ content計算之前設置$新值?
因爲我希望看到'content-start ++ test ++ content-end'
這就是它!謝謝。 – swserg