在Perl中
@array=qw/this is a line
and a new one
then a new one
......
........./;
将导致每个'word'被分配给@array变量。 如何将每个“行”分配给@array变量,即$ a [0] =“这是一行”而不是$ a [0] =“this”
答案 0 :(得分:4)
这是一种方式:
my @array = split / *\n */,
qq/this is a line
and a new one
and another/;