in reply to Please, help understanding y/// transliteration in this example (DON'T TRY executing oneliner)
Here a (Q&D) way to expand a tr expression:
use strict; use warnings; use Data::Dump qw/pp dd/; my $from = q( -/:-@[-`{-}); my $to = q[`-{/" \-]; my @from = expand($from); my @to = expand($to); my %tr; @tr{@from} = @to; pp \%tr; sub expand { my $replace = shift; my $scale = join '' , 0..9,'a'..'z','A'..'Z'; my $code = qq( \$scale =~ tr($scale)($replace)d ); #pp $code; eval $code or warn $@; return split '', $scale; }
-->
{ " " => "`", "!" => "a", "\"" => "b", "#" => "c", "\$" => "d", "%" => "e", "&" => "f", "'" => "g", "(" => "h", ")" => "i", "*" => "j", "+" => "k", "," => "l", "-" => "m", "." => "n", "/" => "o", ":" => "p", ";" => "q", "<" => "r", "=" => "s", ">" => "t", "?" => "u", "\@" => "v", "[" => "w", "\\" => "x", "]" => "y", "^" => "z", "_" => "{", "`" => "/", "{" => "\"", "|" => " ", "}" => "-", }
DISCLAIMER: Neither complete nor even bullet proof.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|