in reply to s/// to replace HTTP address with a space

Without knowing the contents of $file or how you're checking that the "text remains untouched" I don't think that anyone can tell you what you're doing wrong with any certainty. But just to show you that your code does indeed "work":

#!/usr/bin/perl use strict; use warnings; my $str = "This is a string with a URL like http://www.example.com in +it"; print "$str\n"; $str =~ s/http\S+/ /ig; print "$str\n"; __END__ This is a string with a URL like http://www.example.com in it This is a string with a URL like in it

Perhaps it would help you to try to reduce the problem to something simple like the above?