so then if($a=~tr/0/0/c) {do_something();}
should work for any value of true, right? On Wed, 22 May 2002, Ronald J Kimball wrote: > On Wed, May 22, 2002 at 09:54:52PM -0400, Yanick wrote: > > On Wed, May 22, 2002 at 10:06:39PM -0400, Josh Goldberg wrote: > > > I came up with another one. This also works for values of true other > > > than 1. > > > > > > if ($a=~tr/.[^0]+/0/c) { do_something(); } > > > > s/tr/s/, maybe ? > > > > (the transliterate operator doesn't use patterns, so > > the code above change every instances of '.' by a 0, > > of '[' by a '[' and so on and so forth...) > > Actually, it translates every character that is *not* one of '.[^0]+' into '0'. > > /c complements the search list. > > When the search list is longer than the replacement list, the last > character in the replacement class is repeated. > > Ronald > >