Your code probably breaks because there's a syntax error in your substitution, you are missing on slash at the end. It should rather be $attach1 =~ s/$paramstr//;
Anyway, I'd make use of the CGI modulue and its url() method.
use CGI;
my $q = new CGI;
my $url = $q->url(-absolute => 1);