You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Bill Moseley <mo...@hank.org> on 2000/03/08 01:39:10 UTC

uninitialized $@?

This seems odd to me.  I started using Sys::Signal to localize $SIG{ALRM}
(instead of just local $SIG{ALRM}), and now the FIRST request to an Apache
child gives me this warning.  Subsequent requests do not generate the warning.

    Use of uninitialized value at Test.pm line 2659

But 2659 is:
    if ( $@ ) {

I don't see how testing $@ would give that error.



use Sys::Signal ();  # for mod_perl

eval {
    my $h = Sys::Signal->set(ALRM => sub { die "Timed out\n" });
    alarm $timeout;

    $return = read_results( $query, *SEARCH, $start_time );
    alarm 0;
};

if ( $@ ) {   <--- this is 2659

    alarm 0;  # just in case wasn't a timeout that died



Bill Moseley
mailto:moseley@hank.org

Re: uninitialized $@?

Posted by "Rodney Broom (OE)" <rb...@home.com>.
----- Original Message -----
From: "Bill Moseley" <mo...@hank.org>
>     Use of uninitialized value at Test.pm line 2659
> But 2659 is:
>     if ( $@ ) {
> I don't see how testing $@ would give that error.

Hmm, it's late where I am, and I may be missing something... But mod_perl
does cool stuff with variable scoping. (Sometimes not so cool). If nothing
else is going wrong, maybe you just need to turn off the error by saying:
if ( defined($@) ) {...

Although for debugging, I must agree with Ken about changing the line
numbers. Perl does something like crunching out the comments and possibly
some other stuff when it compiles. Thereby returning seemingly incorrect
line numbers for messages. But don't quote me. :-)

Rodney


Re: uninitialized $@?

Posted by Vivek Khera <kh...@kciLink.com>.
>>>>> "A" == Autarch  <au...@urth.org> writes:

A> Perl's a little weird about line numbers in my experience.  I would bet
A> that the actual problem is within the if {} block.

My experience is that within modules the line numbers are accurate.
Only within Registry scripts do the line numbers get mucked up.

But you can verify the line numbers by adding a 

#line 1000000

near the original error, and then narrow down the actual line number
as an offset of that line.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-301-545-6996
PGP & MIME spoken here            http://www.kciLink.com/home/khera/

Re: uninitialized $@?

Posted by Ken Williams <ke...@forum.swarthmore.edu>.
autarch@urth.org (Autarch) wrote:
>On Tue, 7 Mar 2000, Bill Moseley wrote:
>>     Use of uninitialized value at Test.pm line 2659
>> 
>> But 2659 is:
>>     if ( $@ ) {
>> 
>> I don't see how testing $@ would give that error.
>
>Perl's a little weird about line numbers in my experience.  I would bet
>that the actual problem is within the if {} block.

If you suspect that the line numbers are wrong, try putting the following
special comment in the code to reset the line numbering:

   #line 2659 Test.pm
   if ( $@ ) {
     ...

It has to be all the way to the left margin.


  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum



Re: uninitialized $@?

Posted by Autarch <au...@urth.org>.
On Tue, 7 Mar 2000, Bill Moseley wrote:

> This seems odd to me.  I started using Sys::Signal to localize $SIG{ALRM}
> (instead of just local $SIG{ALRM}), and now the FIRST request to an Apache
> child gives me this warning.  Subsequent requests do not generate the warning.
> 
>     Use of uninitialized value at Test.pm line 2659
> 
> But 2659 is:
>     if ( $@ ) {
> 
> I don't see how testing $@ would give that error.

Perl's a little weird about line numbers in my experience.  I would bet
that the actual problem is within the if {} block.


-dave

/*==================
www.urth.org
We await the New Sun
==================*/