[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] How to do variable interpolation in a tr substitution string



> Why am I not able to do this as is in s/([a-z])/$h{$1}/g; etc?

Oh, you're no fun anymore!

> {tr/a-z/$compstr/;print $_;

RTFM perlop(1):

               Note that because the transliteration table is
               built at compile time, neither the SEARCHLIST nor
               the REPLACEMENTLIST are subjected to double quote
               interpolation.  That means that if you want to use
               variables, you must use an eval():

                   eval "tr/$oldlist/$newlist/";
                   die $@ if $@;

                   eval "tr/$oldlist/$newlist/, 1" or die $@;

> Thanks in advance. I am not sure whether it is OK to post this to this
> Mailing List. My apologies if it is inappropriate. 

No, it's not. Please ask technical questions in comp.lang.perl.*

Martin.

-- 
___________________________________________________________________
Martin H. Sluka  \ tel: +49-700-19751024 / "Urmel aus dem IRC(net)"
Pirckheimerstr. 1 >---------------------/ <mailto:martin@sluka.de>
D-91207 Lauf     / fax: +49-9123-13875 /  <http://martin.sluka.de/>

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe