Re: fickle warning

"$Bill Luebkert" <[email protected]> Mon, 26 Sep 2011 01:54:11 -0700
Newsgroups gmane.comp.lang.perl.active-perl
Message-ID <[email protected]>
On Sun, 09/25/2011 22:33, John DePasquale wrote:
> Hi all,
>
> I have what I’m sure is the simplest but nonetheless most vexing problem, I just can’t figure what’s wrong.
>
> I have two perl programs, both web applications. The same line appears in both, which is:
>
> my $cVar = substr( CGI::param( 'x' ), 0, 1 );
>
> sometimes ‘x’ has a value and so $cVar gets a value, other times no value. In the first program, a non-value for x is a non-event and everything is fine.
>
> But in the other program, when there’s a non-value for x I get the error “Use of uninitialized value in substr at . . . “. This error message shows up in my html output so the user sees the error message. I don’t understand why the error is being sent in the html stream to the browser from one program and not the other. Any guidance is greatly appreciated.

I have no idea why - maybe one program uses Carp's fatalsToBrowser
and the other not or some such ?  What happens to the one that
doesn't get the error back to the browser ?  What does it do instead ?
Does it still work ?  What are 'strict' and 'warnings' set to in both ?

The real point is to not let it happen. :)  Fix the code to account
for all possibilities.  I tend to not combine several calls to subs
in one line of code - doesn't hurt to use an intermediate vrbl and
it's a lot easier to debug if you do since you can break on it if
you like or dump the value to a log file.

HTH, Bill
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs