Hughes, Andrew wrote:
As a relative newbie myself, it appears that you have in essence applied a
variable to a variable.  I typically use the format

my $name=param("name");

when I have a form that has a field called name. This form field value
(andrew for example) would be stored in param("name") which is then stored
in the variable $name.

This is one way to think of it, though maybe not the best (at first). You are giving the impression that 'param("name")' is a container and that a value is "stored" in it, which in this case is not strictly correct. 'param' is a function, that takes an argument 'name' (in this case) and performs some action and then returns a value. So in the sense that it is one way to access a particular value when given a particular parameter it appears to "store" the information. However there is no underlying structure 'param' that is storing anything, the value is being generated on the fly everytime. Of course, advanced techniques using 'tie' blur the line here that I am drawing.




That is probably the underlying cause. The OP mentioned that the page worked, is the name displayed correctly? What line number is indicated in the warning, and what line of code is that? This will give you an idea of which value is uninitialized.


http://danconia.org


-----Original Message-----
From: Tony Bandy [mailto:[EMAIL PROTECTED]
Sent: Friday, March 07, 2003 1:43 PM
To: [EMAIL PROTECTED]
Subject: question about uninitialized variable


Hello everyone,


Fairly new to the list here (and perl), so if this is an inappropriate
post, please forgive me. I've got the Learning Perl book plus a few
others...but I'm still scratching my head over this one.

Just a beginning test page where the end-user submits a name and gets a
page back with that name in it.  The page works,however, the warning I
keep getting is:

"Use of uninitialized value in concatenation (.) or string..."

I also noticed this same type of warning when I attempt to take the same
thing (user input) and try to compare it to another variable, using this
example--> $my other variable=~/$name/ operator. I can't get anything to
match.

Here is a snippet of code that will generate the error messsage above:


#!c:\Perl\Perl5.00402\bin\perl.exe -w #Set Perl Parameters #use strict; #The CGI.pm module will take input from the form and process it for you. use CGI qw(:standard); my $name=param("name");

print "<h2>You entered: $name <p>\n";


Thanks in advance for any help you might be able to provide a newbie.





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to