Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have the following hash:
And two functions,:my %key = ( '1'=>'?', '2'=>'/', '3'=>'>', '4'=>'<', '5'=>':', '6'=>';', '7'=>'[', '8'=>']', '9'=>'{', '0'=>'}', '!'=>'p', '@'=>'o', '#'=>'i', '$'=>'d', '%'=>'j', '^'=>'h', '&'=>'g', '*'=>'k', '('=>'5', ')'=>'3', '-'=>'2', '+'=>'9', '='=>'%', '\\'=>'c', '|'=>'1', '~'=>'^' );
andsub decode { my $char; my $meta; foreach $char (keys %key){ $meta =quotemeta $key{$char}; $$message->{body} =~ s/$meta/$char/gis; } }
But when it comes time to encode or decode a message like: this: ^5*9|1(1#|my $char; my $meta; foreach $char (keys %key){ $meta =quotemeta $char; $$message->{body} =~ s/$meta/$key{$char}/gis; }
becomes this: h:k{1?:?i1
ok, not problem, but going th reverse, this: h:k{1?:?i1
becomes this: \~5*9||5|#|
That's a problem ... can you help me understand why it's not doing the correct subs.
thanks, me
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problematice metashar regexp
by Stevie-O (Friar) on Apr 27, 2004 at 22:53 UTC | |
by Anonymous Monk on Apr 28, 2004 at 13:49 UTC | |
|
Re: problematice metashar regexp
by gjb (Vicar) on Apr 27, 2004 at 22:13 UTC | |
by Anonymous Monk on Apr 28, 2004 at 13:42 UTC | |
|
Re: problematice metashar regexp
by bart (Canon) on Apr 28, 2004 at 01:11 UTC | |
|
Re: problematice metashar regexp
by Belgarion (Chaplain) on Apr 27, 2004 at 22:00 UTC |