perl reg expression

I have regular expression like this ( replace + with \+)

($mod_server) = ($server =~ /\+/\\+/g);

the above is failing with error . what's wrong with it .

Thanks

You should post the error message you get. But if that is all the code, the problem appears to be a missing 's' preceeding the regexp:

($mod_server) = ($server =~ s/\+/\\+/g);

The above code will substitute the patten in $server and count the number of times the substitution is true and return that number to $mod_server. Maybe you mean to do this:

$mod_server = $server =~ s/\+/\\+/g;

Which will assign the new value of $server to $mod_server.