Advertisement
T0m

Untitled

T0m
May 6th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.86 KB | None | 0 0
  1. #!/usr/bin/perl
  2. if($#ARGV %2 == 0)
  3. {
  4.     die("Incorrect aantal argumenten meegegeven");
  5. }
  6. %filters;
  7. for($i = 0;$i <= $#ARGV;$i++)
  8. {
  9.     $filters{$ARGV[$i]} = $ARGV[($i+1)];
  10.     $i++;
  11. }
  12. open(FILE,"<mail.in") or die();
  13. $mail = "";
  14. while(<FILE>)
  15. {
  16.     $mail .= $_;
  17. }
  18. close(FILE);
  19. @mails = split(/From /,$mail);
  20. print "Er zijn ".(scalar(@mails)-1)." e-mails!";
  21. open(FILE,"<mail.in") or die();
  22. while(<FILE>)
  23. {
  24.     if(/Subject: (.*)/)
  25.     {
  26.         push(@subjects,$1);
  27.     }
  28. }
  29. close(FILE);
  30. @subjects = sort(@subjects);
  31. print "\n\nGesorteerde onderwerpen\n";
  32. foreach(@subjects)
  33. {
  34.     print $_."\n";
  35. }
  36. print "\nWe zoeken naar emails...\n";
  37. $pattern = "(";
  38. while ( my ($key, $value) = each(%filters) ) {
  39.     $pattern .= "$key: (.*)$value(.*)|";
  40. }
  41. $pattern = substr $pattern,0,-1;
  42. $pattern .= ")";
  43. print $pattern;
  44. foreach(@mails)
  45. {
  46.     if($_ =~ /$pattern/ig)
  47.     {
  48.         print $_;
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement