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
|