Plankton has asked for the wisdom of the Perl Monks concerning the following question:
Friends,
I want to replace all characters ( a-zA-Z ) with another randomly selected character. Here's what I have tried ...
I want to replace all characters ( a-zA-Z ) with another randomly selected character. Here's what I have tried ...
... this was not what I wanted :( I was hopeing for output that looked like this ...$ cat text_ob.pl #!/usr/bin/perl -w use strict; my $randChar = sub () { return chr(int(rand(26)) + 65); }; while (<DATA>) { #s/(\w)/(??{$randChar->()}/g; s/(\w)/$randChar/g; print $_; } __DATA__ ABCDEFG $ ./text_ob.pl CODE(0x1014078c)CODE(0x1014078c)CODE(0x1014078c)CODE(0x1014078c)CODE(0 +x1014078c)CODE(0x1014078c)CODE(0x1014078c)
Am I on the right track or way off?HJAxQPv
Plankton: 1% Evil, 99% Hot Gas. |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: s/\w/random character/g
by Abigail-II (Bishop) on Apr 08, 2004 at 22:18 UTC | |
by davido (Cardinal) on Apr 09, 2004 at 00:52 UTC | |
by Abigail-II (Bishop) on Apr 12, 2004 at 21:26 UTC | |
Re: s/\w/random character/g
by esskar (Deacon) on Apr 08, 2004 at 22:13 UTC | |
Re: s/\w/random character/g
by saintmike (Vicar) on Apr 08, 2004 at 22:17 UTC | |
Re: s/\w/random character/g
by Not_a_Number (Prior) on Apr 08, 2004 at 23:04 UTC | |
Re: s/\w/random character/g
by belg4mit (Prior) on Apr 08, 2004 at 23:14 UTC | |
by Plankton (Vicar) on Apr 09, 2004 at 18:19 UTC |
Back to
Seekers of Perl Wisdom