[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] newbie question: param()


Hi Peter,

At 14:32 25.03.2004 -0500, Michael Peters wrote:

That definitely doesn't seem right. Is that an actual code example that you
copied/pasted, or did you just type it into the email. Sometimes we make
mistakes when we type it in the code and not in the email (and vice versa).

Your assumption is right, while this was part of my actual code, I have shortened it a little to make it less tedious to read. So this is now an actual code
sample:

package WTSubmit;
use lib '/big/dom/xlobstersoft/lib/perl5/site_perl/5.005'; #I don't have root access to the server, so this is where I installed the additional libraries to

use strict;
use warnings;
use Data::FormValidator;
use base qw/CGI::Application/;
use util; #just my own custom library with often used helper functions

##############################
#####  OVERRIDE METHODS  #####
##############################

sub setup {
        my $self = shift;


        #testing a simple string scalar parameter
        $self->param('testparamname','testparamvalue');
        #this prints the following:
        print "\r\nmy parameter value:".$self->param('testparamname')."\r\n";


        #snip... the rest of the code should be irrelevant.





And the actual output is:


linuxplug:/websites/cgidevelopment # perl WTSubmit.pl

my parameter value:testparamname
[Thu Mar 25 20:56:40 2004] WTSubmit.pl: Use of uninitialized value in length at (eval 14) line 11.
Content-Type: text/html; charset=ISO-8859-1

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; lang="en-US" xml:lang="en-US"><head><title>Widget Search Form</title> </head><body><form method="post" action="/WTSubmit.pl" enctype="application/x-www-form-urlencoded"> <input type="text" name="widgetcode" /><input type="hidden" name="rm" value="mode2" /><input type="submit" name=".submit" /><div></div>
</form></body></html>linuxplug:/websites/cgidevelopment #



So, the line "my parameter value:testparamname" shows exactly the strange behavior I have mentioned before.

However, your question has given me the idea to try using only this minimal code snipplet to see if it works. So I ran exactly this:


package helloworld1;

use strict;
use warnings;


use base qw/CGI::Application/;

sub setup {
        my $self = shift;

#setting a simple string scalar parameter with name 'testparamname' and value 'testparamvalue'... At least that's what I am *trying* here.
        $self->param('testparamname','testparamvalue');
        #getting the parameter value again
        print "\r\nmy parameter value:".$self->param('testparamname')."\r\n";

        }
1;

The problem is: It worked fine in this case! But it does not work anymore after adding the line "use util" which refers to my own custom module with often used functions though. So obviously there is some kind of conflict between my module and CGI::Application. But where should I start searching? It's a really big module (>1k lines),so I don't know where to start...

Also, what's with the warning "Use of uninitialized value in length at (eval 14) line 11."? It appears only when I include my module, but I can't make anything out of it. The string "length" does not even appear in my module, so it seems to be referring to someone else's code.


Oh, and by the way, you shouldn't 'print' inside a C::A. That will cause the
output to break in a browser. When I'm testing something I ususally 'die'
(using CGI::Carp so that it still works in the browser) or 'warn' (looking at
the error logs).

Thanks for the advice. I am aware of that, but wanted to keep things as simple as possible with this posting. Usually I am using the regular HTTP output as well.

Thanks,

Adrian Grigore

--
Adrian Grigore
suppressed
Lobstersoft - Fun Brain-Bending Games For All Ages
http://www.lobstersoft.com
Member of the Association of Shareware Professionals


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.