#!/usr/bin/perl use strict; use Getopt::Long; my $buffer; my $help; my $optSpecial; my $optNumber; my $result = GetOptions( "help" => \$help, "append-special=s" => \$optSpecial, "append-number=s" => \$optNumber ); # Add your permutations here! Be imaginative! my @leetList = ("o:0", "i:1", "l:1", "e:3", "a:4", "t:7", "q:9", "c:(", "s:\$"); my @wordList = ("to:2", "for:4", "is:="); if ($help) { print <<_HELP_; Usage: $0 [--help] [--append-special=] [--append-number=] _HELP_ exit 1; } if ($optNumber) { my ($low, $high) = split(":", $optNumber); ($low =~ /^\d+$/ && $high =~ /^\d+$/) || die "Low and high limits must be integers!"; ($low < $high) || die "Low limit must be smaller than high one!"; } # Check if provided file is readable ($ARGV[0] && ! -r $ARGV[0]) && die "Cannot read file \"". $ARGV[0] . "\" (" . $! . ")\n"; open(LIST, (-r $ARGV[0]) ? $ARGV[0] : "-") || die; while() { $buffer = $_; chomp($buffer); my $wordPerm; my $oldbuffer = $buffer; my $pass = 0; foreach $wordPerm(@wordList) { my ($from, $to) = split(":", $wordPerm); $buffer =~ s/$from/$to/g; if (($oldbuffer eq $buffer) && $pass > 0) { next; } $pass++; $oldbuffer = $buffer; my @words = split(" ", $buffer); my $word; my $result; foreach $word(@words) { my $car = lc(substr($word, 0, 1)); $result = $result . $car; } my $leetPerm; my $oldresult = $result; foreach $leetPerm(@leetList) { my ($from, $to) = split(":", $leetPerm); $result =~ s/$from/$to/g; if ($oldresult eq $result) { next; } $oldresult = $result; print "$result\n"; if ($optNumber) { my ($low, $high) = split(":", $optNumber); my $i; for ($i = $low; $i <= $high; $i++) { print "$result" . $i . "\n"; } } if ($optSpecial) { my $special; my @specialList = split("", $optSpecial); foreach $special(@specialList) { print "$result" . $special . "\n"; } } } } } close(LIST); exit(0);