webstudioro has asked for the wisdom of the Perl Monks concerning the following question:

I work with CGI.pm(Carp.pm, Exporter.pm and Util.pm) for my cookies, but show this error.
[Fri Jul 11 15:51:44 2003] (eval 1): Array found where operator expect +ed at (eval 1) line 1, at end of line [Fri Jul 11 15:51:44 2003] (eva +l 1): (Do you need to predeclare Carp::longmess?) [Fri Jul 11 15:51:44 2003] (eval 1): Array found where operator expected at (eval 1) line 2, at e +nd of line [Fri Jul 11 15:51:44 2003] (eval 1): (Do you need to predeclare Carp:: +shortmess?) [Fri Jul 11 15:51:44 2003] (eval 1): Array found where operator expect +ed at (eval 1) line 3, at end of line [Fri Jul 11 15:51:44 2003] (eval 1): (Do you n +eed to predeclare Carp::shortmess?) [Fri Jul 11 15:51:44 2003] (eval 1): Array found wh +ere operator expected at (eval 1) line 4, at end of line [Fri Jul 11 15:51:44 2003] + (eval 1): (Do you need to predeclare Carp::longmess?) Undefined subroutine &Carp +::longmess called at Carp.pm line 296.
My system: Windows xp with sambar server 5.2

My script is:
#!/usr/bin/perl use CGI; require "admin_sub.pl"; require "uzual_sub.pl"; require "variabile.pl"; &readForm; if ($FORM{'verify'} eq "account") { if (($FORM{'user'} eq "$adminUser") && ($FORM{'pws'} eq "$adminPas +sword")) { $query = new CGI; $cookie = $query->cookie(-name=>'$adminUser',-value=>'$adminPasswo +rd',-expires=>'+1y',-path=>'/',-domain=>'localhost',-secure=>'0'); print $query->header(-cookie=>$cookie); print "Content-type: text/html\n\n"; print "The cookie is: $ENV{'HTTP-COOKIE'}"; exit; } else { print "Content-type: text/html\n\n"; print "Error ."; exit; } exit; } print "Content-type: text/html\n\n"; print <<ENDHTML; <html> <head> <title>$websiteTitle</title> </head> <body> <table align=center border=0> <form action="http://localhost/cgi-bin/admin.pl" method="post"> <input type=hidden name="verify" value="account"> <tr><td> User: <input type=text name="user"><br> Password: <input type=password name="pws"><br> <input type=submit value="Log in!"> </td></tr> </form> </table> </body> </html> ENDHTML exit;

edited: Fri Jul 11 13:17:53 2003 by jeffa - code tags ... sigh

Replies are listed 'Best First'.
(jeffa) Re: CGI.pm error
by jeffa (Bishop) on Jul 11, 2003 at 13:31 UTC
    Hi webstudioro. You really need to sit down and read some directions first. This is the second post of yours that i have cleaned up by adding code tags and removing those pesky <br> tags you insist on using. I also retitled Help with cookie not being displayed. Please take the time to familiarize yourself with how things are done at this site. Did you not see this disclaimer:
    • Are you posting in the right place? Check out Where do I post X? to know for sure.
    • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following: a, b, big, blockquote, br, center, dd, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, li, ol, p, pre, readmore, small, span, strike, strong, sub, sup, table, td, th, tr, tt, u, ul
    • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible editor intervention).
    • Want more info? How to link or How to display code and escape characters are good places to start.
    It's there for a reason - to prevent people like me from downvoting you and editors from having to clean up your mess.

    Onward: you question. Is exactly what again? You need to trim your questions down. Find the point that is giving you trouble and write a smaller script to demonstrate the error. However, you have SOOO many problems that i recommend you stop what you are doing and read Ovid's online CGI Course. Point in case. Your errors all point towards a problem with how you use Carp.pm ... yet nowhere in the code you have given do we see where 'longmess' is actually called. It is most likely buried somewhere in one of these three files:

    require "admin_sub.pl"; require "uzual_sub.pl"; require "variabile.pl";
    And since we have no idea what those look like ... we can't answer your question. Please take the time ask a good question. Ovid said it best when he said "Clean your room!" If you want to know what bad questions are, just read (the very lengthy) How (Not) To Ask A Question.

    We are here to help, but you have to help us help you first.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      Well said,
      In addition, I am loathe to spend time trying to figure out errors in code that is written without use strict and warnings. Especially when the poster received several replies to his last post pointing out that they should be using strict.

      -pete
      "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."
      OK. I'm sorry.
        It's ok. You don't have to be sorry, this whole business just isn't very nice to newbies, but there is a reason for it. Here is some cookie code that i wrote about a year ago. Maybe it will help you get a feel for what you need to do.
        use strict; use warnings; use CGI qw(:standard); use CGI::Cookie; my @views = qw(first second third fourth fifth sixth seventh eighth); my %cookies = CGI::Cookie->fetch(); my $x = (defined $cookies{'cookie_i'}) ? $cookies{'cookie_i'}->value() : 0 ; my $view = $views[$x++]; my $cookie = CGI::Cookie->new(-name=>'cookie_i',-value=>$x % @views); print header(-cookie=>$cookie), start_html('session'), h1($view), start_form, submit, end_form, end_html ;
        Just name it foo.cgi or something and run it from a browser that accepts cookies. Hope this helps. :)

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        
Re: CGI.pm error
by demerphq (Chancellor) on Jul 12, 2003 at 12:17 UTC

    You say you are using Carp. I dont believe you. The error messages that you have displayed clearly shows that Carp has _not_ loaded properly. The only explanation that I can think for the error messages that you are displaying is that Carp::Heavy has somehow disappeared from your system. I think that you are almost certainly doing something very wrong, the error messages you see there should basically not be possible with a properly installed version of perl.

    Reinstall perl and try this again. And DONT MESS WITH THE STANDARD MODULES!!!! If you do, you wont get much sympathy from the folks around here.


    ---
    demerphq

    <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...