Acme-LeetSpeak

 view release on metacpan or  search on metacpan

lib/Acme/LeetSpeak.pm  view on Meta::CPAN

    'h', [ '#', '/-/', '[-]', ']-[', ')-(', '}{', '|-|' ], 
    'i', [ '1', '!', '|', '][', ], 
    'j', [ '_|', '_/', ],
    'k', [ '|<', ], 
    'l', [ '1', '7', '1_', '|', '|_', ], 
    'm', [ '|\\/|', '/\\/\\', '/|/|', ], 
    'n', [ '|\\|', '/\\/', '[\\]', ], 
    'o', [ '()', 'oh', '0', ], 
    'p', [ '|o', '|*', '|>', ], 
    'q', [ '0_', '(,)', ], 
    'r', [ 'r' ], 
    's', [ '5', '$', ],
    't', [ '7', '+', ],
    'u', [ '(_)', '|_|', ], 
    'v', [ '\\/', '\\|', '|/', ], 
    'w', [ '\\/\\/', '\\^/', '\v/', ], 
    'x', [ '><', '}{', ], 
    'y', [ 'j', '¥', '`/', ], 
    'z', [ 'z' ], 
);

our $CHANCE_OF_LEET_CHAR = 5; # out of 10
our $CHANCE_OF_UPPER_CHAR = 5; 

sub leet {
	my $text = shift;
    return unless defined $text and $text ne '' and $text !~ /^\s+$/;
    foreach my $rule ( @LEET_WORD_MAP ) { 
            if ( $text =~ $rule->[INPUT] && int( rand 9 ) < $rule->[CHANCE] ) {
                my $find = $rule->[INPUT];
                my $switch = $rule->[OUTPUTS]->[ rand @{ $rule->[OUTPUTS] } ];
                $text =~ s/$find/$switch/i;
            }
    }
    $text =~ s/([a-z])/_leetchar($1)/ige;
    return $text;
}

sub _leetchar {
    my $char = shift;
    if ( int( rand 9 ) < $CHANCE_OF_LEET_CHAR ) {
        my $leet = $LEET_CHAR_MAP{lc $char};
        $char = $leet->[ rand @{ $leet } ];
    }
    if ( int( rand 9 ) < $CHANCE_OF_UPPER_CHAR ) {
        $char = uc $char;
    }
	return $char;
}

=head1 AUTHOR

Jordan M. Adler, C<< <jmadler at cpan.org> >>

=head1 BUGS

Please report any bugs or feature requests to
C<bug-acme-leetspeak at rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Acme-LeetSpeak>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Acme::LeetSpeak

You can also look for information at:

=over 4

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/Acme-LeetSpeak>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/Acme-LeetSpeak>

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Acme-LeetSpeak>

=item * Search CPAN

L<http://search.cpan.org/dist/Acme-LeetSpeak>

=back

=head1 ACKNOWLEDGEMENTS

=head1 COPYRIGHT & LICENSE

Copyright 2007 Jordan M. Adler, all rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut

1; # End of Acme::LeetSpeak



( run in 1.431 second using v1.01-cache-2.11-cpan-b301d465b3d )