in reply to s/\w/random character/g

Ignoring whitespace and symbols (which you seem to be) wouldn;t it be easier to just create a random string to start off with?

--
I'm not belgian but I play one on TV.

Replies are listed 'Best First'.
Re: Re: s/\w/random character/g
by Plankton (Vicar) on Apr 09, 2004 at 18:19 UTC
    Hi belg4mit,

    Actually I do care about white space and etc though you can't tell that from my original post. With the help I got from you helpful monks here's what I ended up with ...
    $ cat text_ob.pl #!/usr/bin/perl -w use strict; sub randchar { return chr int(rand(26)) + 65; } sub randchar2 { my $t = shift; return chr int(rand(26)) + 65 if $t =~ /[a-zA-Z]/; return int(rand(9)) if $t =~ /\d/; return $t; } while (<>) { s/(.)/&randchar2($1)/ge; print $_; } $ ./text_ob.pl < text_ob.pl #!/VYX/ZEE/AOIV -M MVV AMGMXL; YHN DTRQSXDS { GJAHJL MMY BMO(OLTR(18)) + 70; } FZJ EVXHJEPY7 { KP $U = RLOFG; VCDZBZ VOD GAU(GHOE(70)) + 67 ZF $F =~ /[E-V|D-K]/; RPYZOA ADX(ERSW(1)) EM $E =~ /\R/; GDQIZW $W; } VKSXA (<>) { F/(.)/&XDGFXIBL8($8)/QW; DTMTE $_; }