一个简单的过滤器我有一个包含了一堆邮件,看起来像这样一个文件:创建在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