Re: [問題] 關於一段程式輸出的問題
perldoc perlvar
$LIST_SEPARATOR
$" This is like $, except that it applies to array and slice val-
ues interpolated into a double-quoted string (or similar inter-
preted string). Default is a space. (Mnemonic: obvious, I
think.)
因為它的預設值是一個空白
所以你直接把陣列內插進字串時就會產生這種現象
※ 引述《chuankun (歡迎光臨)》之銘言:
: @str = <STDIN>;
: @str = sort @str;
: print "@str";
: 想請問一下為什麼 print那一列有加 "" 時 @str印出來的時候不能對齊?
: 例如
: <STDIN>輸入
: a
: c
: b
: 執行結果卻是
: a
: b #前面多一個空白
: c #前面多一個空白
: 如果不加""結果就正常
: a
: b
: c
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.244.211
討論串 (同標題文章)
Perl 近期熱門文章
PTT數位生活區 即時熱門文章