I don't think quotemeta is what you want in this case... the '@' and '$' symbols still cause interpolation even inside of the "\Q" usage of quotemeta. You can use the quotemeta() function to escape them, but then you'll also print the backslashes. This happens because the string isn't interpolated recursively. Consider the following:
#!/usr/bin/perl -wT use strict; ## wrong, causes error # print "\Qblakem@foo1.com\E\n"; ## wrong, prints the backslashes print quotemeta('blakem@foo2.com'),"\n"; ## wrong, still prints backslashes my $escaped = quotemeta('blakem@foo3.com'); print "$escaped\n"; print $escaped, "\n"; ## right my $email = 'blakem@foo4.com'; print "$email\n"; ## right print "blakem\@foo5.com\n"; print 'blakem@foo6.com',"\n"; =output blakem\@foo2\.com blakem\@foo3\.com blakem\@foo3\.com blakem@foo4.com blakem@foo5.com blakem@foo6.com
From perlop:
You cannot include a literal $ or @ within a \Q sequence. An unescaped + $ or @ interpolates the corresponding variable, while escaping will cause the literal stri +ng \$ to be inserted. You'll need to write something like m/\Quser\E\@\Qhost/.
So, either put the backslash in by hand if you are simply printing the string
print "blakem\@foo.com"; print 'blakem@foo.com';
or assign it to a scalar and print the scalar
my $email = 'blakem@foo.com'; print $email;

-Blake


In reply to Re: Re: @ symbol in html output by blakem
in thread @ symbol in html output by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.