Guest User

Untitled

a guest
Jul 12th, 2017
586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. grep -v '@bad.com' inputfile > outputfile
  2.  
  3. findstr /v "@bad.com" inputfile > outputfile
  4.  
  5. use Email::Address;
  6.  
  7. my $data = 'this person email is [email protected]
  8. blah blah [email protected] blah blah
  9. ';
  10.  
  11. my @emails = Email::Address->parse( $data );
  12. my @good_emails = grep { $_->host ne 'bad.com' } @emails;
  13.  
  14. say "@good_emails"; # => [email protected]
  15.  
  16. $badDomain = "bad.com";
  17. while(<>)
  18. {
  19. s{s+$}{};
  20. print "$_n" if(!/@$badDomain$/);
  21. }
  22.  
  23. my $bad_addresses = {'bad.com'=>1};
  24.  
  25. while (my $s = <>) {
  26. print $s unless (is_bad_address($s));
  27. }
  28.  
  29. sub is_bad_address {
  30. my ($addr) = @_;
  31. if ($addr=~/^([^@]+)@([^@nr]+)$/o) {
  32. my $domain = lc($2);
  33. return 0 unless (defined $bad_addresses->{$domain});
  34. return $bad_addresses->{$domain};
  35. }
  36. return 1;
  37. }
  38.  
  39. use strict;
  40. use warnings;
  41.  
  42. my @re = map { qr/@(.*.)*Q$_E$/ } qw(bad.com mean.com);
  43.  
  44. while (my $line = <DATA>) {
  45. chomp $line;
  46. if (grep { $line =~ /$_/ } @re) {
  47. print "Rejected: $linen";
  48. } else {
  49. print "Allowed: $linen";
  50. }
  51. }
  52.  
  53. __DATA__
  54.  
  55. perl -ne 'print if !/@bad.com/' file
  56.  
  57. awk '!/@bad.com/' file
  58.  
  59. my @array = <>;
  60.  
  61. foreach(@array) {
  62. if(!/@bad.com$/) {
  63. print $_;
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment