一個簡單的過濾器我有一個包含了一堆郵件,看起來像這樣一個文件:創建在Perl
From: [email protected]
Date: 10 Nov 2014 09:19:59 +0100 (MET)
To: [email protected]
Subject: Let's go have a beer
Hey Jonny, let's have a drink tonight. See ya, Tommy
From: [email protected]
Date: 11 Dec 2014 19:16:49 +0100 (MET)
To: [email protected]
Subject: Meeting
Dear Martha,
Note that our Monday meeting will take place at 10:00 instead of 13:00.
Best regards,
Alice
等
我寫一個Perl腳本,允許用戶從給輸入標題並給他回覆一條消息。例如,
,用戶可能鍵入from alice subject meeting
並且會得到電子郵件。
到目前爲止,我有這個代碼,我不知道如何着手
open(IN, "<emails.txt") or die "Can't open the file";
print "Enter the search elements from the header:\n";
chomp($input=<STDIN>);
# example input from alice subject meeting
($from, $who, $where, $what)=split/ /, $input;
while (<IN>)
{
if(/$from(.)+$who/i){
while (<IN>){
if(/$where(.)+$what/i){
while ($line = <IN>){
print $line;
}
}
}
}
}
恐怕「不確定如何繼續」意味着您的問題可能對於堆棧溢出而言過於寬泛。如果你有一個特定的事情,你有問題,那麼它可以有意義的回答。 – Sobrique 2015-03-31 11:36:39
@Sobique謝謝你的評論。我希望有人能找到邏輯上的缺陷,並給我正確的方向。 – Nat 2015-03-31 11:40:42