use strict; use warnings; use Test::More tests => 3; my $have = 'https://abc.abc:8080/abc?abcdef&abc=&egh?'; my $want = 'https://def.def/abc?abcdef&abc=&egh?'; my $try = $have; substr ($try, 8, 12, 'def.def'); is ($try, $want, 'substr'); ($try = $have) =~ s/\Qabc.abc:8080/def.def/; is ($try, $want, 'quotemeta regex'); my @bits = split ('/', $have, 4); $bits[2] = 'def.def'; $try = join '/', @bits; is ($try, $want, 'split/join');