Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- if($#ARGV %2 == 0)
- {
- die("Incorrect aantal argumenten meegegeven");
- }
- %filters;
- for($i = 0;$i <= $#ARGV;$i++)
- {
- $filters{$ARGV[$i]} = $ARGV[($i+1)];
- $i++;
- }
- open(FILE,"<mail.in") or die();
- $mail = "";
- while(<FILE>)
- {
- $mail .= $_;
- }
- close(FILE);
- @mails = split(/From /,$mail);
- print "Er zijn ".(scalar(@mails)-1)." e-mails!";
- open(FILE,"<mail.in") or die();
- while(<FILE>)
- {
- if(/Subject: (.*)/)
- {
- push(@subjects,$1);
- }
- }
- close(FILE);
- @subjects = sort(@subjects);
- print "\n\nGesorteerde onderwerpen\n";
- foreach(@subjects)
- {
- print $_."\n";
- }
- print "\nWe zoeken naar emails...\n";
- $pattern = "(";
- while ( my ($key, $value) = each(%filters) ) {
- $pattern .= "$key: (.*)$value(.*)|";
- }
- $pattern = substr $pattern,0,-1;
- $pattern .= ")";
- print $pattern;
- foreach(@mails)
- {
- if($_ =~ /$pattern/ig)
- {
- print $_;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement