+ -
当前位置:首页 → 问答吧 → 求助map的问题

求助map的问题

时间:2010-12-16

来源:互联网

  1. my @line = ("U    /home/admin/build/app/core/s",
  2.             "U    /home/admin/test/app/core/s",
  3.             "U    /thdir/admin/test/app/core/s");
  4.             
  5. my @newline = map {$_=~s/^U    \//\//, $_}@line;

  6. print "line is @newline\n";
复制代码
结果输出如下:
line is 1 /home/admin/build/app/core/s 1 /home/admin/test/app/core/s 1 /thdir/ad
min/test/app/core/s

1和后面的空格从哪儿来啊?

作者: nfwolf   发布时间: 2010-12-16

map {$_=~s/^U    \//\//, $_}@line

改为:

map {$_=~s/^U    \//\//; $_}@line

作者: 黑色阳光_cu   发布时间: 2010-12-16