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


in reply to Regular expression "replace string interpolation" problem

What about this replace text, which attempts to lower case the protocol and hostname in a URL string, but leave the path (and anything else) as is:

my $url = 'http://www.FOo.COm/wibbLE'; my $search = '^([^:]+://[^/]+)/?(.*)?$'; my $replace = '\L$1\E/$2'; printf "%s\n", $url if ($url =~ s!$search!$replace!);

Anyone got a way of not resorting to "/e" or "/ee" or eval to make this work? For me the $replace is coming from a database, and I don't trust the code so I dont want it doing an "unlink /" or similar! :)