in reply to @ symbol in html output

The problems you would be experiencing relate to the interpolation of the address "email@address.com" with the value of the @address. The solution will revolve around either escaping meta characters such as @ with a backslash (\) or printing without interpolation - See quotemeta and perlop for further details.

 

Ooohhh, Rob no beer function well without!

Replies are listed 'Best First'.
Re: Re: @ symbol in html output
by blakem (Monsignor) on Sep 23, 2001 at 11:53 UTC
    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