Home: Perl Programming Help: Intermediate:
Cookies and text with milk.


Jan 31, 2000, 10:57 PM

Views: 4701
Cookies and text with milk.

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";
The problem is it will read the cookie
as $usrname! Not the value of $usrname but just $usrname.


Feb 1, 2000, 3:28 PM

Views: 4701
Re: Cookies and text with milk.

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.


'$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:


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:


Good luck!

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