NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page typos - perl

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
9 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 03-30-2007, 07:03 PM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Dec 2005
Posts: 43
spiderninja is an unknown quantity at this point
 



typos - perl


PHP Code:
use strict;

# http://www.spiderninja.com/
# ninja@spiderninja.com

my @qw(spider ninja);

for (@
a) {
    print 
make_typos($_), "\n";
}

sub make_typos {
    
my $word shift;
    
my @typos;
    
push @typosskip_letter($word);
    
push @typosdouble_letters($word);
    
push @typosreverse_letters($word);
    
push @typosskip_spaces($word);
    
push @typosmissed_key($word);
    
push @typosinserted_key($word);
    return 
join ","map "\"$_\"" } @typos;
}

sub skip_letter {
    
my @split(//, shift);
    
my @a;
    for (
my $x 0$x < @l$x++) {
        
next if ($l[$xeq ' ');
        
my $s;
        for (
my $y 0$y < @l$y++) {
????: NamePros.com http://www.namepros.com/code/311233-typos-perl.html
            
next if ($y == $x);
            
$s .= $l[$y];
        }
        
push @a$s;
    }
    return @
a;
}

sub double_letters {
    
my @split(//, shift);
    
my @a;
    for (
my $x 0$x < @l$x++) {
        
next if ($l[$xeq ' ');
        
my $s;
        for (
my $y 0$y < @l$y++) {
            
$s .= $l[$y];
            if (
$y == $x) {
                
$s .= $l[$y];
            }
        }
        
push @a$s;
    }
    return @
a;
}

sub reverse_letters {
    
my @split(//, shift);
    
my @a;
    for (
my $x 0$x < @1$x++) {
        
next if ($l[$xeq ' ' || $l[$xeq $l[$x+1]);
????: NamePros.com http://www.namepros.com/showthread.php?t=311233
        
my $s;
        for (
my $y 0$y < @l$y++) {
            if (
$y == $x && $x < @l) {
                
$s .= $l[$y+1];
            } 
elsif ($y == $x+1) {
                
$s .= $l[$y-1];
            } else {
                
$s .= $l[$y];
            }
        }
        
push @a$s;
    }
    return @
a;
}

sub skip_spaces {
    
my @split(//, shift);
    
my (@whitespace_pos$i);
    for 
my $letter (@l) {
        if (
$letter eq ' ') {
            
push @whitespace_pos$i;
        }
        
$i++
    }
    
my @a;
    for (@
whitespace_pos) {
        
my $s;
        for 
my $x (.. $#l) {
            
if ($_ == $x) {
                
next;
            } else {
                
$s .= $l[$x];
            }
        }
        
push @a$s;
    }
    return @
a;
}

sub missed_key {
    
my @split(//, lc(shift));
    
my %atoz get_alphabet();
    
my @a;
    for (
my $x 0$x < @l$x++) {
        
next if ($l[$xeq ' ' || !$atoz{$l[$x]});
        for (
my $y 0$y < @{$atoz{$l[$x]}}; $y++) {
            
my $s;
            for (
my $z 0$z < @l$z++) {
                if (
$x == $z) {
                    
$s .= ${$atoz{$l[$x]}}[$y];
                } else {
                    
$s .= $l[$z];
                }
            }
            
push @a$s;
        }
    }
    return @
a;
}

sub inserted_key {
    
my @split(//, lc(shift));
    
my @a;
    
my %atoz get_alphabet();
    for (
my $x 0$x < @l$x++) {
        
next if ($l[$xeq ' ' || !$atoz{$l[$x]});
        for (
my $y 0$y < @{$atoz{$l[$x]}}; $y++) {
            
my ($axbc$abxc);
            for (
my $z 0$z < @l$z++) {
                if (
$x == $z) {
                    
$axbc .= ${$atoz{$l[$x]}}[$y];
                    
$axbc .= $l[$z];
                    
$abxc .= $l[$z];
                    
$abxc .= ${$atoz{$l[$x]}}[$y];
                } else {
                    
$axbc .= $l[$z];
                    
$abxc .= $l[$z];
                }
            }
            
push @a$axbc;
            
push @a$abxc;
        }
    }
    return @
a;
}

sub get_alphabet {
    
my %alphabet = (=> ["1""2""w""s""a"],
                    
=> ["q""2""3""e""d""s""a"],
                    
=> ["w""3""4""r""f""d""s"],
                    
=> ["e""4""5""t""g""f""d"],
                    
=> ["r""5""6""y""h""g""f"],
                    
=> ["t""6""7""u""j""h""g"],
                    
=> ["y""7""8""i""k""j""h"],
                    
=> ["u""8""9""o""l""k""j"],
                    
=> ["i""9""0""p""l""k"],
                    
=> ["o""0""l"],
                    
=> ["q""w""s""x""z"],
                    
=> ["a""w""e""d""x""z"],
                    
=> ["s""e""r""f""c""x"],
                    
=> ["d""r""t""g""v""c"],
                    
=> ["f""t""y""h""b""v"],
                    
=> ["g""y""u""j""n""b"],
                    
=> ["h""u""i""k""m""n"],
                    
=> ["j""i""o""l""m"],
                    
=> ["k""o""p"],
                    
=> ["a""s""x"],
                    
=> ["z""s""d""c"],
                    
=> ["x""d""f""v"],
                    
=> ["c""f""g""b"],
                    
=> ["v""g""h""n"],
                    
=> ["b""h""j""m"],
                    
=> ["n""j""k"],
    );
    return %
alphabet;

ahhhh...beautiful ;-) I should rewrite it in PHP and post again
__________________
Spider Ninja's free SEO tools
Last edited by spiderninja; 03-30-2007 at 09:29 PM.
spiderninja is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 03:41 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger