Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
584
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 hacker@bad.com
  8. blah blah hacker@good.com blah blah
  9. another@bad.com
  10. ';
  11.  
  12. my @emails = Email::Address->parse( $data );
  13. my @good_emails = grep { $_->host ne 'bad.com' } @emails;
  14.  
  15. say "@emails"; # => hacker@bad.com hacker@good.com another@bad.com
  16. say "@good_emails"; # => hacker@good.com
  17.  
  18. $badDomain = "bad.com";
  19. while(<>)
  20. {
  21. s{s+$}{};
  22. print "$_n" if(!/@$badDomain$/);
  23. }
  24.  
  25. my $bad_addresses = {'bad.com'=>1};
  26.  
  27. while (my $s = <>) {
  28. print $s unless (is_bad_address($s));
  29. }
  30.  
  31. sub is_bad_address {
  32. my ($addr) = @_;
  33. if ($addr=~/^([^@]+)@([^@nr]+)$/o) {
  34. my $domain = lc($2);
  35. return 0 unless (defined $bad_addresses->{$domain});
  36. return $bad_addresses->{$domain};
  37. }
  38. return 1;
  39. }
  40.  
  41. use strict;
  42. use warnings;
  43.  
  44. my @re = map { qr/@(.*.)*Q$_E$/ } qw(bad.com mean.com);
  45.  
  46. while (my $line = <DATA>) {
  47. chomp $line;
  48. if (grep { $line =~ /$_/ } @re) {
  49. print "Rejected: $linen";
  50. } else {
  51. print "Allowed: $linen";
  52. }
  53. }
  54.  
  55. __DATA__
  56. good@good.com
  57. bad@bad.com
  58. notbad@bad.comm.com
  59. alsobad@bad.com
  60. othergood@good.com
  61. not@mean.com
  62. good@reallymean.com
  63. bad@really.mean.com
  64.  
  65. perl -ne 'print if !/@bad.com/' file
  66.  
  67. awk '!/@bad.com/' file
  68.  
  69. my @array = <>;
  70.  
  71. foreach(@array) {
  72. if(!/@bad.com$/) {
  73. print $_;
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement