in reply to Substitution Trickery


Why not omit the test. If there isn't a trailing / then it won't be removed:
# Remove trailing / if present $served =~ s/\/$//;

--
John.

Replies are listed 'Best First'.
Re: Re: Substitution Trickery
by jasonk (Parson) on Mar 21, 2003 at 15:56 UTC

    The test turns '/foo/' into '/foo', but avoids turning '/' into ''.


    We're not surrounded, we're in a target-rich environment!

      True but that isn't in the psuedo-code that lacertus presents.

      His test would also leave a trailing slash on 'foo/bar/'. Is that what is required? Perhaps lacertus will tell us.

      If it is required then the following would suffice:

      $served =~ s[/$][] if $served =~ m[^/.];

      --
      John.