On Sunday 21 October 2007 23:45, Michael Alipio wrote:
> Hi,
Hello,
> I'm trying to create a dictionary file for my
> bruteforce program.
>
>
> I have a huge dictionary file and I want to trim it
> down according the requirements.
>
> The output should be a dictionary file that is minimum
> 6 characters and maximum 15 characters with at least 4
> letters and 2 numbers in it.. no special characters
What do you mean by "special characters"?
> whatsoever.. This should be a simple regex but it's
> been a while since i wrote my last regexp program.
> Need to refresh my perl basics a little bit..
>
>
> So far I got this:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
>
> my $wordlist = shift @ARGV;
> #my $newwordlist = shift @ARGV;
>
> open INPUTFILE, "$wordlist" or die $!;
> #open OUTPUTFILE, ">$output" or die $!;
>
> while (<INPUTFILE>){
> next if !(/\b\w\w\w\w\b/);
> print;
>
> }
Perhaps something like this [UNTESTED]:
#!/usr/bin/perl
use warnings;
use strict;
@ARGV == 2 or die "usage: $0 wordlist newwordlist\n";
my ( $wordlist, $newwordlist ) = @ARGV;
open INPUTFILE, '<', $wordlist or die "Cannot open '$wordlist' $!";
#open OUTPUTFILE, '>', $output or die "Cannot open '$output' $!";
while ( <INPUTFILE> ) {
next unless /\A[[:alnum:]]{6,15}\z/;
next unless tr/a-zA-Z// >= 4;
next unless tr/0-9// >= 2
print;
}
__END__
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/