An update of tested code to previously untested code...

#!/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

In reply to Re: Re: English to h4x0r translator by parv
in thread English to h4x0r translator by Trag

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.