我有一個Perl腳本,目前抓住包含單詞ACCOUNT
的每一行。我怎樣才能在行首開始抓住包含單詞ACCOUNT
的行?如何匹配以特定單詞開頭的行?
use strict;
my $find = 'ACCOUNT';
open (NEW, ">", "output.txt") or die "could not open:$!";
open (FILE, "<", "Report.txt") or die "could not open:$!";
while (<FILE>) {
print NEW if (/$find/);
}
close (FILE);
close (NEW);
僅僅在一開始,或者如果有空白,然後「ACCOUNT」,它可以嗎? – aschepler
這並不難。我相信會有很多人排隊要求他們給出答案的十點,但是你怎麼做才能自己找到答案?谷歌是一個方便的工具 – Borodin
我同意@Borodin。 [答案](http://perldoc.perl.org/perlre.html#Regular-Expressions)[out](http://www.regular-expressions.info/anchors.html),並不是很很難[找](https://regex101.com)。 –