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: Intermediate:
Cookies and text with milk.

 



patk
Deleted

Jan 31, 2000, 10:57 PM

Post #1 of 2 (1491 views)
Cookies and text with milk. Can't Post

Hello! I downloaded Matt Wright's
cookie-lib and I am attempting
to set a cookie with the value
of a login id.
$usrname = "someuser_from_succesful_login";
&SetCookies('SMM-ID','$usrname');
The problem is it will read the cookie
as $usrname! Not the value of $usrname but just $usrname.


Jasmine
Administrator

Feb 1, 2000, 3:28 PM

Post #2 of 2 (1491 views)
Re: Cookies and text with milk. [In reply to] Can't Post

The problem is that you have '$usrname' in between single quotes. If you want to interpolate the scalar (get the value of $usrname), then enclose it in double quotes.

Using single quotes around a scalar or other variable will tell Perl to treat the text within it literally.

So...

'$username' is treated literally as $username

"$username" has a special character in it, so Perl interpolates it and gives you the value of $username, instead of the word $username

Simple change the &SetCookies line to:

&SetCookies('SMM-ID',"$usrname");

Also, in the way you're using the scalar (as a lone variable being passed to a subroutine), you can omit the quotes completely and use:

&SetCookies('SMM-ID',$usrname);

Good luck!


[This message has been edited by Jasmine (edited 02-01-2000).]

 
 


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

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