use Lingua::31337 'text231337';
$Lingua::31337::LEVEL = 9;
die text231337 "Hi. I like CPAN :)$/";
__END__
H1. 1 1IK0 cPAn :)
MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | ** The third rule of perl club is a statement of fact: pod is sexy. |
| [reply] [d/l] |
I find myself needing a reverse translator. I think adding a
option, say -r, & putting the translations in a hash would allow that.
Something like the untested code below ...
my %map =
( 'a' => '4'
, 'e' => '3'
, 'h' => '|-|'
, 'i' => '1'
, 'l' => '1'
, 'o' => '0'
, 's' => '5'
, 't' => '7'
) ;
# $reverse is set by some other means
@map{ values %map } = keys %map if $reverse ;
while ( <DATA> )
{ foreach my $k ( keys %map )
{ s/ $k / $map{$k} /giex;
}
print;
}
| [reply] [d/l] |
#!/usr/local/bin/perl
use warnings;
use strict;
# An naive attempt to cross translate between '3133+' speak & readabl
+e
# enough English.
#
# English conversion is bound to have gross spelling errors. No doub
+t,
# it sure could use some additions in $letter, $group and $word.
# Spelling check and soundex related modules could also be brought in
# to produce even more readable language.
# Set to a true value if converting from '3133+' to 'elite'
my $reverse = 1;
# Mapping
our
( $word
, $group
, $letter
);
if ( $reverse )
{ transform_hash( $_ )
foreach $word , $group , $letter;
}
while ( my $line = <> )
{
replace_word( $line , $word );
foreach my $map ( $group , $letter )
{
foreach my $k ( keys %{$map} )
{
foreach my $el ( @{ $map->{$k} } ) { $line =~ s/\Q$k/$el/gi; }
}
}
print $line;
}
BEGIN
{ our $word =
{ 'hacker' => [ qw( haxor ) ]
, 'for' => [ qw( 4 ) ]
};
our $group =
{ 'orn' => [ qw( r0n 0rn ) ]
};
our $letter =
{ 'a' => [ qw( 4 @ ) ]
, 'c' => [ qw/ ( / ]
, 'd' => [ qw/ |) / ]
, 'e' => [ qw( 3 ) ]
, 'h' => [ qw( |-| ) ]
, 'i' => [ qw( 1 ) ]
, 'l' => [ qw( 1 |_ ) ]
, 'm' => [ qw( |V| |\\/| ) ]
, 'n' => [ qw( |\\| ) ]
, 'o' => [ qw( 0 ) ]
, 's' => [ qw( 5 ) ]
, 't' => [ qw( 7 + ) ]
, 'w' => [ qw( \\/\\/ ) ]
} ;
}
sub replace_word
{ my ($line , $map) = @_;
foreach my $k ( keys %{$map} )
{ foreach my $word ( @{ $map->{$k} } )
{
# Needs better right word boundary than '\s' or '\b'. For examp
+le,
# it would fail to convert '4' at the end of a sentence to 'for'
+.
$line =~ s/ \b $k (?=\s) /$word/gix;
}
}
$_[0] = $line;
}
sub transform_hash
{ my $hash = shift;
foreach my $k ( keys %{$hash} )
{
foreach my $v ( @{ $hash->{$k} } ) { $hash->{$v} = [$k]; }
delete $hash->{$k};
}
}
- Input: 4ny h31p w17h the tr4n514710n 45p3c75 w0u1d b3
4ppr3c14t3d, 4s w0u1d 4ny 5ugg35710n5.
- Output: any heip with the transiation aspects wouid be
appreciated, as wouid any suggestions.
- Input: 45 \/\/45 4|_r34|)y p01|\|+3d @u7, +|-|3Re 15 @ |\/|0|)u1e
+h@t c4|\| do0 7h1s 4 y0o. T|-|Er3 1s |\/|u(h m0r3 y0u c@|\| |)0 +o
t3X+ t|-|4n 51mp73 r3p7@ce|\/|en+5.
- Output: as was already pointed aut, theRe is a moduie that can
doo this for yoo. ThEre is much more you can do to teXt than simpte
reptacements.
- Parv
| [reply] [d/l] |
45 \/\/45 4|_r34|)y p01|\|+3d @u7, +|-|3Re 15 @ |\/|0|)u1e +h@t c4|\| do0 7h1s 4 y0o. T|-|Er3 1s |\/|u(h m0r3 y0u c@|\| |)0 +o t3X+ t|-|4n 51mp73 r3p7@ce|\/|en+5.
| [reply] |
| [reply] |