【发布时间】:2015-11-12 00:34:50
【问题描述】:
我有一个看起来像这样的文件:
hellothisisline1
andthisisline2hi
yepthisistheline
我想将这些行连接成一个字符串
hellothisisline1andthisisline2hiyepthisistheline
print "Input file name \n";
open (FILE, <>);
$string = "";
while($line = <FILE>) {
$string = $string . "" . $line;
}
print "$string \n";
但这似乎不起作用,输出是原始格式的文件。
【问题讨论】:
-
$ perl -lne '$all .= $_; END {print $all}' yourfile.txt
标签: perl