2012-09-15 132 views
1

是否可以讓Perl忽略字符串中的換行符?忽略字符串中的換行符

因爲我有很長的字符串,我需要換行符來格式化原因。

E.g.

print "hello 
world" 

應當給予

hello world 

,而不是

hello 
world 

回答

4

拼接你的字符串

print "hello" 
    . "world"; 
2

您可以將多個字符串print而不是一個大單:

print "hello", "world"; 

假設,當然,你還沒有跟$,瞎搞的,並且你真的使用print

+1

哦,這比concatenation = =更合理)我已經寫了任何Perl幾年了! – paddy

+2

@paddy:但它只在打印時才起作用,'如果你正在做'my $ s =「hello」這樣的事情,它們就是要走的路。 「世界」;'。 –

0

1.使用級聯

打印 「你好」。 「世界」;

2.通過發送多個參數到打印功能

打印( 「你好」, 「世界」);

codepad上嘗試。