using diagnostics....

D

Dave

Hi,

I am using strict and warnings. I have also unsucessfully looked online
in google and perldocs on how to localize a filehandle (though I'm not
sure that is what I need to be doing). I get the following error when I
turn on diagnostics. :

Use of uninitialized value in concatenation (.) or string at
/usr/lib/perl5/site_perl/5.8.0/UUMembers.pm line 362 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a
mistake.
To suppress this warning assign a defined value to your variables.


The corresponding code id:

361: print "Content-type: text/html\n\n";
362: print<<X;
363: <head>
364: X

What do I need to do in order to code this correctly? What is the
error? How do I define X to something?

I will have more html in between line 362 and 364, otherwise I would
have simply used a print command.

Thanks in advance,
Dave
 
D

Dave

I'm in the process of getting a short version of the program to
generate the error... please don't bother with this post until I post
that...
 
D

Dave

Rrr... It won't replicate with a smaller program... but the same code
(or at least I can't tell any difference, as I copied and pasted from
the large program) gives that warning in the large program.

Does that look like an improper way to do something, or does anyone
have any idea what *could* be going on off the top of their heads?

Thanks,
Dave
 
D

Dave

So it looks like it is working fine on the web when one of the
variables I have between my 'X' things is defined, but it is undefined
when run from the shell, so it gives that error.

Sorry to muddy up the newsgroup with this.

Dave
 
C

ced

Dave said:
I am using strict and warnings. I have also unsucessfully looked online
in google and perldocs on how to localize a filehandle (though I'm not
sure that is what I need to be doing).

perldoc -q local

(scroll down until you see:
How can I make a filehandle local to a subroutine?
How do I pass filehandles between subroutines?
How do I make an array of filehandles?
I get the following error when I
turn on diagnostics. :

Use of uninitialized value in concatenation (.) or string at
/usr/lib/perl5/site_perl/5.8.0/UUMembers.pm line 362 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a
mistake.
To suppress this warning assign a defined value to your variables.


The corresponding code id:

361: print "Content-type: text/html\n\n";
362: print<<X;
363: <head>
364: X

What do I need to do in order to code this correctly? What is the
error? How do I define X to something?

I will have more html in between line 362 and 364, otherwise I would
have simply used a print command.

If a variable, say $foo is declared but is never initialized
and then embedded in your here-doc, Perl will emit the warning
you've just seen. If you get this warning and there are several
embedded variables in a here-doc or if-else structure, Perl can't
drill down closely enough to tell you which one is undefined.

Often just inspecting the code closely and debugging on the
command line will provide clues. By the way, the CGI module or
equivalent is also easier and preferable to hand rolling HTML.
You could even arrange to display warnings to the screen which
may make them easier to spot:

use CGI qw/:standard warningsToBrowser/;
warningsToBrowser(1);
print header, start_html;

print <<X;
...$foo ....
...... $bar
X
# print "embedded variable \$foo is $foo"; # var. defined test
# print "embedded variable \$bar is $bar";

print end_html;
__END__


hth,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top