in reply to Search and replace for @

I think :
$string =~ s/@/\\@/g;
But, i dont think perl will have a problem with $string because it is only a problem during string declaration.
OH, a sarcasm detector, that’s really useful

Replies are listed 'Best First'.
Re: Re: Search and replace for @
by earthboundmisfit (Chaplain) on Jul 16, 2001 at 19:30 UTC
    Also, when you populate $string, make sure you use single quotes so @foo is not interpreted as an array variable
    $string = 'foo@foo.com'; $string =~ s/\@/\\@/g;
Re: Re: Search and replace for @
by Masem (Monsignor) on Jul 16, 2001 at 19:40 UTC
    That's a very important point; unless you explicitly type into your code the email address, you don't need to escape the @ symbol. So populating $string from a database would need no extra work (and trying to do what you do may screw up the system later by introducing an unneeded backslash).
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain