CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
@ character within a scalar variable string

 



new2perl84
Novice

Jul 6, 2009, 5:24 AM

Post #1 of 4 (318 views)
@ character within a scalar variable string Can't Post

I'm trying to assign a string of text to a scalar variable which contains the @ character. Is there any way of doing this without the Perl application thinking that i'm trying to place an array variable into the string?

i've read that \Q and \E can be used to turn off 'special characters' but either im using them incorrectly or they dnt work for @'s

I'd be grateful for any help anyone could give!

Thanks in advance


spider
User


Jul 6, 2009, 5:32 AM

Post #2 of 4 (315 views)
Re: [new2perl84] @ character within a scalar variable string [In reply to] Can't Post

If you uses single quotes it should work.

Ex:

Code
my($email) = 'name@domain.com' ;


If you need to combine this with your other scalars you can do something like this:

Code
$email = $name . '@' . $domain ;



shawnhcorey
Enthusiast


Jul 6, 2009, 5:53 AM

Post #3 of 4 (311 views)
Re: [spider] @ character within a scalar variable string [In reply to] Can't Post


In Reply To
If you uses single quotes it should work.

Ex:

Code
my($email) = 'name@domain.com' ;


If you need to combine this with your other scalars you can do something like this:

Code
$email = $name . '@' . $domain ;



You can also escape it with a backslash:

Code
$email = "$name\@$domain";


See `perldoc perlop` and search for the section /Quote and Quote-like Operators/.

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


new2perl84
Novice

Jul 6, 2009, 6:19 AM

Post #4 of 4 (307 views)
Re: [spider] @ character within a scalar variable string [In reply to] Can't Post

Thanks very much! thats exactly what i needed




In Reply To
If you uses single quotes it should work.

Ex:

Code
 my($email) = 'name@domain.com' ;


If you need to combine this with your other scalars you can do something like this:

Code
 $email = $name . '@' . $domain ;



 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives