in reply to Detecting whether forward slash is present in string

philuk86zen,
I would think URI would be of some help here, but the following code should also work:
my $end = chop $string1; my $beg = chop reverse $string2; my $url = $string1 . ($end eq '/' ? '' : $end) . '/' . ($beg eq '/' ? +'' : $beg) . $string2;

Cheers - L~R

I am trying to avoid regexes today as noted by this node

Replies are listed 'Best First'.
Re^2: Detecting whether forward slash is present in string
by ysth (Canon) on Sep 13, 2004 at 22:33 UTC
    chop reverse doesn't work; try $beg = substr($string2,0,1,'');  (Untested, of course :)
      ysth,
      I am glad I put the should also work disclaimer in there ;-)

      You are of course correct. Lesson learned - always state your code is untested if you are rushing off to have dinner with your wife.

      Cheers - L~R