in reply to Substituting in the substitution!

$_='ABC AB AB12/83'; tr / \//_/; print

Plankton: 1% Evil, 99% Hot Gas.

Replies are listed 'Best First'.
Re: Re: Substituting in the substitution!
by ambrus (Abbot) on May 06, 2004 at 17:00 UTC

    Why's the space before the backslash?

    Update: ah, I forgot. Perl repeats the last character of the right side of the tr if there are too few. Great.

      Because that way both spaces and slashes get translated into underscores. This strips out the brackets as well:
      $_='[ABC AB AB12/83]'; tr# /[]#__#d; print;

      The PerlMonk tr/// Advocate