1
我想將文本/字符串存儲在數據庫的文本字段中。
該字符串中包含變量$ name。
當我將它從數據庫中拉出時,我希望在打印字符串之前將該變量替換爲我定義的值。如何將變量文本存儲到數據庫中?
# Variable I want to substitute #
1. $name='John';
# needs to be read from database #
2. $txt{'hello'}="Hello ${name}, How are you?";
3. print "<tag>$txt{'hello'}</tag>";
它打印Hello John, How are you?
根據需要,但是,當第二行被從數據庫中讀出,它顯示Hello ${name}, How are you?
。
有些事情,我發現是:
Locale::Maketext
$string =~ s/(\$\w+)/$1/eeg;
my $string = sprintf 'Say hello to %s and %s', $foo, $bar;
有人能指導我如何做呢?