Perl脚本在匹配中删除空格

时间:2016-03-18 18:43:49

标签: perl

我的脚本效果很好,但我遇到的问题是它正在组合匹配中的所有单词并删除间距。如果有人可以帮我告诉我我还有什么额外的东西,或者我错过了以防止剧本组合比赛中的单词。

use strict;

my $find = '^M0|MT';
my $match = 0;

open (NEW, ">", "Output.txt" ) or die "could not open:$!";
open (FILE, "<", "File.txt") or die "could not open:$!";

while (<FILE>) {
    chomp;

if ($match){
    $match = 0;
    s/\s+//g;
    print NEW "$_\n";
}

if (/$find/){
    $match = 1;
    print NEW "$_"
}
}
close (FILE);
close (NEW);

文件示例

          U# mul acc       UNIT # HAS MULTIPLE ACCOUNTS          FAIL

输出示例(我的脚本当前正在发生什么)

          U#mulaccUNIT#HASMULTIPLEACCOUNTSFAIL

1 个答案:

答案 0 :(得分:1)

由于@ThisSuitIsBlackNot已经指出:

该行

var layerTest = CAShapeLayer()

var bzPath = UIBezierPath(roundedRect: vwView.bounds, byRoundingCorners: [.BottomLeft, .BottomRight], cornerRadii: CGSizeMake(10, 10) )
layerTest.path = bzPath.CGPath

vwView.layer.mask = layerTest;

正在吃你的空间。它声明:用一个空格替换一个或多个空格的序列,并重复输入完整的输入字符串。

看起来你打算说:

s/\s+//g;

所以,只需用一个空格替换空格序列。

相关问题