2014-04-26 170 views
-2

我期待以下信息將被打印在CMD提示 預期值:如何在Perl打印值

(set "a=10") 

CMD:

@value = "(set " . \"a=10)\""; 
print @value; 

O/P:

(set SCALAR(0x43f8f0)& echo %a% 

回答

2

錯誤位置的反斜槓,

@value = "(set " . "\"a=10\")"; 

輸出

(set "a=10") 

或者乾脆

my $value = q{(set "a=10")}; 

perlop

+0

謝謝你的寶貴意見.. – user3571518

1
@value = "(set " . \"a=10)\""; 
      ^^
       | | 
     String end. | 
        | 
      Outside quotes, 
     this means reference. 

報價選項爲什麼你需要一個數組呢?

$value = '(set "a=10")'; 
print $value;