damian1301 has asked for the wisdom of the Perl Monks concerning the following question:

Well, I have this script that I have been messing with and adding random features to lately. The problem is when I added this one subroutine today I get an error. It's basically a blank error and all it says is
Uncaught exception in user code:
Nothing else, no helping error for me to find out what the problem is. Here is the subroutine.
sub weather{ no strict; my $weather = new Geo::Weather; my $zip_code= param('zip_code'); if($zip_code && $report){ $zip_code =~ s/\D//ig; $zip_code =~ s/\d{6,}//; if($report eq 'Temperature'){ my $current = $weather->get_weather($zip_code); print "The current temperature is $current->{temp} degrees +\n"; }elsif ($report eq 'Full'){ $weather->get_weather('); print $weather->report(); }else{ print "Not valid"; # Just for security } }else{ print "Enter your zip code, please."; print start_form; print textfield(-name=>'zip_code',maxlength=>'5'); print "What kind of report do you want?"; print popup_menu({-name=>'report',-value=>['Temperature','Full +'],-default=>'Temperature'}); print hidden('node','weather'); print submit(-value=>'Submit'); my $report = param('report'); } }
I have no idea what is wrong here so PLEASE help me. PS. I'm using CGI.pm and Geo::Weather. just FYI. Thanks in advance.

Wanna be perl hacker.
Dave AKA damian

I encourage you to email me

Replies are listed 'Best First'.
Re: Blank error problems..
by chromatic (Archbishop) on Jan 31, 2001 at 06:41 UTC
    If this is a direct cut and paste, you have a problem with:

    $weather->get_weather(');

    Unbalanced quotes really screw things up, and give wacky errors.

    Besides that, there's no reason to undo strict here, and your second regex looks to be whacking any zip code. I'd be surprised if you were passing anything to Geo::Weather after it.

    I'll assume that the definition of $report at the very end is a typo, and that it's supposed to be at the beginning.

    strict would have caught most of these, but unbalanced quotes throw off the whole parser. I run into that with my stuff every couple of days.

Re: Blank error problems..
by runrig (Abbot) on Jan 31, 2001 at 06:26 UTC
    Just MHO, but now might be a good time to learn the debugger (my preference). Or scatter debug type 'print' statements throughout your code (yuck).
Re: Blank error problems..
by dws (Chancellor) on Jan 31, 2001 at 10:05 UTC
    A minute of searching shows that the "uncaught exception" message originates (at least) in diagnostics.pm

    What a marvelous place for a breakpoint!