#!/usr/local/bin/perl use warnings; use strict; # An naive attempt to cross translate between '3133+' speak & readable # enough English. # # English conversion is bound to have gross spelling errors. No doubt, # 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 example, # 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}; } }