http://www.perlmonks.org?node_id=28839

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm using tr to count the '/' characters in a string...unfortunately, I can't escape it with a '\' (perl barfs). Any ideas?
  • Comment on How do i escape a '/' character when using tr?

Replies are listed 'Best First'.
Re: How do i escape a '/' character when using tr?
by merlyn (Sage) on Aug 21, 2000 at 20:43 UTC
    That's odd.
    $count_slash = tr/\///;
    works just fine in my copy of Perl. Or you can use an alternate delimiter:
    $count_slash = tr#/##;