in reply to problematice metashar regexp

Also, if you're only doing character-by-character replacements, you may want to give tr/// a shot. You can do it all in one go:
# note that I used {} as the delimiter for tr/// $foo =~ tr{1234567890!@#$%^&*()-+=\\|~} {?/><:;[]{}poidjhgk5329%c1^};
This would also help prevent a potential problem: your hash maps '5' to ':' and '(' to '5'. If Perl happens to order your hash so keys finds the second of these first, Perl will change '('s in the string to '5's, then later on change those converted '5's to ':'s. tr/// does everything in one shot, so that sort of thing won't happen.
--Stevie-O
$"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc

Replies are listed 'Best First'.
Re: Re: problematice metashar regexp
by Anonymous Monk on Apr 28, 2004 at 13:49 UTC
    This looks pretty darn good as well.

    Trying to play with this, can something like this work?

    my $str1="1234567890!@#$%^&*()-+=\|~"; my $str2="?/><:;[]{}poidjhgk5329%c1^"; $foo =~ tr{$str1}{$str2};
    thanks you so much!