Skip to content

Instantly share code, notes, and snippets.

@v4p0r
Created December 6, 2017 17:18
Show Gist options
  • Save v4p0r/90b06d4f1bd196012e98b48aebb8a666 to your computer and use it in GitHub Desktop.
Save v4p0r/90b06d4f1bd196012e98b48aebb8a666 to your computer and use it in GitHub Desktop.
unless
#!/usr/bin/perl
use strict;
use warnings;
my $optList = $ARGV[0];
my $help = "perl $0 -l <list.txt> \n".
"perl $0 --list <list.txt>\n";
sub uniq {
my %seen;
grep !$seen{$_}++, @_;
}
print "==========================\n" .
" # Filter Text \n" .
" # Coder: v4p0r \n" .
"==========================\n\n";
die "$help" unless $optList;
if(($optList eq "-l") || ($optList eq "--list")){
my $list = $ARGV[1];
if (defined($list)) {
test($list);
} else {
print "[-] Cade a lista amigao?\n";
}
}
sub test {
my $list = shift;
open (my $wolf,'<',$list) or die "[-] Lista nao encontrada amigao\n";
print "[!] Lista: ".$list."\n";
my @filter = <$wolf>;
my @filtered = uniq(@filter);
print "[!] Carregados: ".scalar(@filter)."\n";
print "[!] Filtrados: ".scalar(@filtered)."\n\n";
foreach my $one(@filtered) {
open(my $fh, '>>', 'filtrado.txt');
print $fh "$one";
close $fh;
}
print "[!] Fenish :)\n" .
"[+] Feliz Natal e Boas Festas!";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment