Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

1 0\/\/Nz U DoodZ!

by IndyZ (Friar)
on Feb 18, 2001 at 10:35 UTC ( #59222=snippet: print w/replies, xml ) Need Help??
Description: After reading this node, I dusted off one of my oldest perl scripts. If you can't tell, I had just discovered regular expressions.

That last paragraph haxorfied:
4f73r r34d1n9 }{4c|<1n9, 1 du$73d 0ff 0n3 0f my 01d357 p3r1 5cr1p7z.

You can see, it goes really overboard, but I have actually seen people talk like this. Ahh, the joys of USENET.

#!/usr/bin/perl

srand;

sub ran { return $_[( rand (scalar @_ ))] }  # Allow random choices


while (<>) {

$data = $_;
# The conversion rules.
# Watch the order if you decide to add your own.
# Use the e regex switch and the "ran" function with a list of possibi
+lities
#   to pick a random possibility.

#Phrase conversions

$data =~ s/(\btoo\b|\bto\b)\b/2/gi; 
$data =~ s/\belite\b/ran("eleet","leet")/gie;
$data =~ s/\bdude/d00d/gi;
$data =~ s/\bfile/phyle/gi;
$data =~ s/\byou\b\b/ran("u","you","u","u")/gie;  # Make "u" way more 
+probable
$data =~ s/\bcool\b/ran("kool","kewl")/gie;
$data =~ s/\bhacker/haxor/gi;



#Single character conversions

$data =~ s/ss^\b/ran("55","\$\$","\$\$")/gie;
$data =~ s/s\b/ran("z","\$", "z")/gie;     #s -word boundary to z     
$data =~ s/e/3/gi;
$data =~ s/t/7/gi;
$data =~ s/(l|i)/1/gi;
$data =~ s/a/4/gi;
$data =~ s/s/ran("5","\$","\$","\$")/gie;
$data =~ s/b/8/gi;
$data =~ s/g/9/gi;
$data =~ s/o/0/gi;
$data =~ s/n/ran("\/\\\/","n","n")/gie;  #Huh? Convert n to /\/
$data =~ s/h/ran("h","\}\{")/gie;    # h to }{
$data =~ s/k/ran("k","\|\<")/gie;
$data =~ s/w/\\\/\\\//gi; # w to \/\/

print $data;

}
Replies are listed 'Best First'.
Re: 1 0\/\/Nz U DoodZ!
by japhy (Canon) on Feb 18, 2001 at 11:51 UTC
    Some comments on the latter half of translations:
    $data =~ s/ss^\b/ran("55","\$\$","\$\$")/gie;
    That ^ makes no sense.
    $data =~ s/e/3/gi; $data =~ s/t/7/gi; $data =~ s/(l|i)/1/gi; $data =~ s/a/4/gi; $data =~ s/b/8/gi; $data =~ s/g/9/gi; $data =~ s/o/0/gi;
    Ewww. This would be so much better as a tr///.
    $data =~ tr/eEtTlLiIaAbBgGoO/3377111144889900/;


    japhy -- Perl and Regex Hacker
      $data =~ s/ss^\b/ran("55","\$\$","\$\$")/gie;
      That ^ makes no sense.


      He's trying to make "$$" a more probable outcome than "55"... if you have a bag with one red hat and two black hats, and you pick one at random, chances are better for picking a black hat than a red one...
      I kinda like the way he did that... it's strangely creative :)
Re: 1 0\/\/Nz U DoodZ!
by davorg (Chancellor) on Feb 18, 2001 at 13:40 UTC

    If it's worth doing (and in many cases even if it isn't worth doing) it's on CPAN. Have you seen Text::Bastardize? --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: snippet [id://59222]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2022-09-27 17:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (122 votes). Check out past polls.

    Notices?