Acme-LeetSpeak
view release on metacpan or search on metacpan
lib/Acme/LeetSpeak.pm view on Meta::CPAN
...
my $leet = leet( $string );
=head1 FUNCTIONS
=head2 leet
=cut
use constant {
INPUT => 0,
CHANCE => 1,
OUTPUTS => 2,
};
our @LEET_WORD_MAP = (
# pre number-ization
# words
[ '\bfear\b', 10, [ 'phear', ], ],
[ '\bp(?:ro|or)n\w*\b', 10, [ 'pron', ] ],
[ '\belite\b', 10, [ 'eleet', 'leet', ], ],
[ '\bdo\b', 9, [ 'do', 'doo', ], ],
lib/Acme/LeetSpeak.pm view on Meta::CPAN
'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 ) {
( run in 0.512 second using v1.01-cache-2.11-cpan-4e96b696675 )