SPUG: Unitialized values

Dave Campbell campbell at geospiza.com
Thu Jun 1 17:42:40 CDT 2000


Seems hard to say without the subs what might be undefined.  what about
a couple of lines to catch the undefs before they are used, whereupon
you can address them specifically.  For example:

20 unless( defined $dbSystem ) { print "The variable dbSystem is
undefined\n"; }
21 my $status = param('action');
22 unless( defined $status ) { print "The function call param('action')
returns undefined\n"; }



>         I have a script that is always throwing up warnings, and I can't
> for the life of me figure out what it's warning me about.  I tried to
> find a description of the error in the perl man pages, but I'm still
> pretty new to it and didn't have any luck.  Anyone have any ideas?  The
> code is as follows, minus its subs (I added the numbering for
> reference):
> 
> 1  #!/usr/bin/perl -w
> 2
> 3  ###############################################
> 4  #
> 5  # Page for setting up a new data source.
> 6  # It does several things:
> 7  #    1)  Collects information about what client it goes too, what the
> name of it is, and gets the text file that contains the data
> 8  #    2)  Collects information about the structure of the data
> 9  #    3)  Imports data according to it's structure
> 20 #
> 11 ###############################################
> 12
> 13 use strict;
> 14 use CGI qw(:standard);
> 15 use DBI;
> 16
> 17 require "./DashboardLib.pl";
> 18
> 19 my $dbSystem =
> DBI->connect("DBI:mysql:database=Development;host=localhost","root","");
> 20
> 21
> 22 #Start Main
> 23 print header();
> 24
> 25 if (param('Action') eq 'GetTableStructure') {print
> GetTableStructure($dbSystem)}
> 26 elsif ((param('Action') eq 'StartImport') || (!param())) {print
> StartImport($dbSystem)};
> 27
> 28 $dbSystem->disconnect();
> 29 #End Main
> 
>         The errors that I'm getting are:
> 
> Use of uninitialized value at /usr/local/apache/cgi-bin/SetupDB.pl line
> 25.
> Use of uninitialized value at /usr/local/apache/cgi-bin/SetupDB.pl line
> 26.
> 
>         Any help y'all could provide would be much appreciated.
> Thanks,
> Peter Darley
> 
>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>      POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
>  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
>  For Subscriptions, Email to majordomo at pm.org:  ACTION  spug-list  EMAIL
>   Replace ACTION by subscribe or unsubscribe, EMAIL by your Email address

-- 
Dave Campbell
Geospiza, Inc.
619 N 35th St. Suite 101M
(206) 633-4403
campbell at geospiza.com

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 For Subscriptions, Email to majordomo at pm.org:  ACTION  spug-list  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email address





More information about the spug-list mailing list