homepage Welcome to WebmasterWorld Guest from 54.166.105.24
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Cookie question
works in one script, not in another
basenotes




msg:430200
 9:33 pm on Oct 25, 2004 (gmt 0)

Hi folks

I'm not an expert in coding Perl, but thanks to my father's insistance on learning BASIC at the age of 7, I'm not too bad at editing scripts and adding a few bits too them (sometimes!)

I have a cookie query.

In one script, I'm using the following code to read a cookie which has been set by a different script:


===================================
use CGI qw(header cookie);
.
.
.
$theCookie = $query->cookie('username');

===================================

This works fine, and I can use the string '$theCookie' for what I need.

However, when I use the same code in another script, it doesn't work (I get a 500 error) and my host's perl tester gives a response of:


===================================
- 255 perl returned nonzero status
Global symbol "$theCookie" requires explicit package name at /kunden/homepages/22/d83025052/htdocs/basenotes/cgi-bin/auction.cgi line 28.
Global symbol "$query" requires explicit package name at /kunden/homepages/22/d83025052/htdocs/basenotes/cgi-bin/auction.cgi line 28.
/kunden/homepages/22/d83025052/htdocs/basenotes/cgi-bin/auction.cgi had compilation errors.
STDOUT OK STDERR OK
===================================

ANyone have any ideas as to what would cause it to work in one and not another. Is there a bit of code I've missed?

 

upside




msg:430201
 11:30 pm on Oct 25, 2004 (gmt 0)

You need to declare the variable $theCookie probably like this:

[b]my[/b] $theCookie = $query->cookie('username');

quebrada




msg:430202
 5:36 am on Oct 27, 2004 (gmt 0)

You can also take out the pragma use strict;

It is better not to use global variables at all or at least confine them to a name space, which is what the error message is stating.

Q

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved