使用perl here ducoment时<<之后的标识符和最后的标识符必须一致,包括空格。例如,
C:\Documents and Settings\Administrator>perl
$var = << HERE_TARGET; --多了一个空格,perl并不认为是"HERE_TARGET"
your text
goes here
HERE_TARGET
$var =~ s/^\s+//gm;
print $var;
^D --此时没有任何输出,perl认为还没有结束
^C
C:\Documents and Settings\Administrator>perl
($var = < your text
goes here
HERE_TARGET
print $var;
^D
your text
goes here
如果一定要使用空格,可以将HERE_TARGET包含在引号(单引号或双引号)中。例如,
C:\Documents and Settings\Administrator>perl
($var = <<" HERE_TARGET") =~ s/^\s+//gm;
your text
goes here
HERE_TARGET
print $var;
^D
your text
goes here
阅读(674) | 评论(0) | 转发(0) |