[rt-users] escaping @ in email addresses in RT_SiteConfig.pm -- todo or not to do?

Jim Meyer purp at acm.org
Mon Jan 30 14:06:49 EST 2006


Hello!

On Mon, 2006-01-30 at 10:57, Hasan Muhammad wrote:
> --- "Schultz, Eric" <ESchultz at corp.untd.com> wrote:
> 
> > You ran into a Perlism :-)  Single quotes don't interpolate the special
> > character '@' - double quotes do.  Which is why you have to escape it
> > with double quotes. 
> 
> ..but is not this line that caused the error message...
> >   Set($OwnerEmail, "admin at test-network.us");
> ...already escaped with double quotes? 

Those double quotes cause Perl to examine the string between them,
looking for variable names to expand. Since Perl considers "@foo" the
same as join(" ", @foo), it wants to interpolate @test as a Perl array
... which it isn't, so you get the complaint you mentioned. Putting a
backslash ahead of the @ explains to Perl that it's really just an @.

If you put it all in single quotes, Perl considers that a string literal
which it shouldn't examine, so no complaints.

The end result: Don't put email addresses in double quotes if you can
avoid it; if you can't avoid it, you need to use \@.

Cheers!

--j
-- 
Jim Meyer, Geek at Large                                    purp at acm.org




More information about the rt-users mailing list