Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to print an object and its arguments

Posted on 2006-07-12
1
Medium Priority
?
187 Views
Last Modified: 2013-12-25
An HTML form sends input to this cgi program.  I would like to know how to print the value of
one or all of the cookie's values out of the object.  At present it outputs a blank string if cookies are enabled, but generates a server error indicating:

"uninitialized value in concatenation or string" at the line indicated.





#!/usr/bin/perl -wT
#
#

use strict;
use lib '/Volumes/mojo/toppweb/ttest/squid/squidperl';
use CGI qw( :standard);
use CGI::Cookie;

use constant SOURCE_CGI => "/tsquid/ctest2.html";

chomp (my $inval = param("cart_id") );
my $q= new CGI;

my $kookie = $q->cookie(-name => "tcooky",
                  -value => $inval,
                  -path  => "mt1.stanford.edu",
                   );

                              
if ( $inval )  {
#   print $q->redirect( SOURCE_CGI );
  print
        $q->header( -type => "text/html", -expires => "-1d" ),                  
        $q->start_html("Cookie Enabled"),
        $q->h1("Cookies Enabled [" . $q->cookie('tcooky') ."]"),           <--- error occurs here
       $q->p( "Your browser IS accepting cookies ",
       $q->a( { -href => SOURCE_CGI }, "Return" ),
       "."
       ),
       $q->end_html;



} else {
  print
        $q->header( -type => "text/html", -expires => "-1d" ),                   
        $q->start_html('Cookie Disabled'),
        $q->h1("Cookies Disabled " ),
       $q->p( "Your browser is not accepting cookies. ",
       $q->a( { -href => SOURCE_CGI }, "Return" ),
       "."
       ),
       $q->end_html;
}
exit (0);




0
Comment
Question by:gmanpert
1 Comment
 
LVL 8

Accepted Solution

by:
Perl_Diver earned 1500 total points
ID: 17093020
you define a cookie but never read or write a cookie. The CGI module can handle the cookies, you don't need to also use CGI::Cookie. See if this helps you:

http://perldoc.perl.org/CGI.html#HTTP-COOKIES
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Suggested Courses

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question