in reply to Substitution Trickery

Try this:
$served =~ s/\/$// if ($served =~ /^\/.+?\/$/);
You're setting $served equal to whether or not the substitution happened. Substitution is an in-place modifier.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: Substitution Trickery
by Thelonius (Priest) on Mar 21, 2003 at 15:54 UTC
    dragonchild has the right answer, but you could improve the readability of the statement various ways:
    $served =~ s!/$!! if $served =~ m!^/.+/$!; or $served =~ s!/$!! if $served =~ m!^/.!; or $served =~ s!(^/.+)/$!$1!;