Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grep -v '@bad.com' inputfile > outputfile
- findstr /v "@bad.com" inputfile > outputfile
- use Email::Address;
- my $data = 'this person email is hacker@bad.com
- blah blah hacker@good.com blah blah
- another@bad.com
- ';
- my @emails = Email::Address->parse( $data );
- my @good_emails = grep { $_->host ne 'bad.com' } @emails;
- say "@emails"; # => hacker@bad.com hacker@good.com another@bad.com
- say "@good_emails"; # => hacker@good.com
- $badDomain = "bad.com";
- while(<>)
- {
- s{s+$}{};
- print "$_n" if(!/@$badDomain$/);
- }
- my $bad_addresses = {'bad.com'=>1};
- while (my $s = <>) {
- print $s unless (is_bad_address($s));
- }
- sub is_bad_address {
- my ($addr) = @_;
- if ($addr=~/^([^@]+)@([^@nr]+)$/o) {
- my $domain = lc($2);
- return 0 unless (defined $bad_addresses->{$domain});
- return $bad_addresses->{$domain};
- }
- return 1;
- }
- use strict;
- use warnings;
- my @re = map { qr/@(.*.)*Q$_E$/ } qw(bad.com mean.com);
- while (my $line = <DATA>) {
- chomp $line;
- if (grep { $line =~ /$_/ } @re) {
- print "Rejected: $linen";
- } else {
- print "Allowed: $linen";
- }
- }
- __DATA__
- good@good.com
- bad@bad.com
- notbad@bad.comm.com
- alsobad@bad.com
- othergood@good.com
- not@mean.com
- good@reallymean.com
- bad@really.mean.com
- perl -ne 'print if !/@bad.com/' file
- awk '!/@bad.com/' file
- my @array = <>;
- foreach(@array) {
- if(!/@bad.com$/) {
- print $_;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement