On Thursday 07 June 2001 16:56, Peter Cline wrote:
> When using the -w I am getting the following set of warnings that prohibit
> execution of the code:
>
> Use of uninitialized value at
> /oracle/web/docs-intranet/cgi/dispatcher/lib/request_sub.lib line 18,
> <CONF> chunk 1.
> Use of uninitialized value at
> /oracle/web/docs-intranet/cgi/dispatcher/lib/request_sub.lib line 18,
> <CONF> chunk 2.
> Use of uninitialized value at
> /oracle/web/docs-intranet/cgi/dispatcher/lib/request_sub.lib line 18,
> <CONF> chunk 3.
> Use of uninitialized value at
> /oracle/web/docs-intranet/cgi/dispatcher/lib/request_sub.lib line 18,
> <CONF> chunk 7.
> Use of uninitialized value at
> /oracle/web/docs-intranet/cgi/dispatcher/lib/request_sub.lib line 18,
> <CONF> chunk 8.
> Use of uninitialized value at
> /oracle/web/docs-intranet/cgi/dispatcher/lib/request_sub.lib line 18,
> <CONF> chunk 38.
>
> The code executes fine without the -w flag.  Here is the code about which
> the interpreter complains:
>
> sub processConfFile {
>     my ($configFile, $conf, $varValueSep, $configComment) = @_;
>     my ($input) = "";
>     my ($comment) = "";
>     my ($var) = "";
>     my ($value) = "";
>
>     open (CONF, "$$configFile") || die("Could not open config file
> $$configFile.");
>
>     while (<CONF>) {
>        ($input, $comment) = split(/$$configComment/);
>        chomp($input);
>        ($var, $value) = split(/$$varValueSep/, $input);  #line 18, the one
> the interpreter complains about
>        if (($var ne "") && ($value ne "")) {
>           $var =~ s/^\s*(.*)\s*$/$1/;
>           $value =~ s/^\s*(.*)\s*$/$1/;
>           $$conf{$var} = $value;
>        }
>     }
> }
>
> 1;
>
> What I do not understand is that the variables in use here, namely
> $var,$value,$input, and $varValueSep (reference passed to subroutine)  are
> all initialized!  So what's the interpreter complaining about?  And what
> the heck is a chunk?


1) warnings do not prohibit the execution. they are just warnings, not errors.

2) variables are initialized, but some of them are initialized from the 
parameters. So, if you pass undefined value as a parameter, the variable can 
contain undefined value. That's what perl complains about - you're then using 
the undefined value in wrong context.

It would be of help if you told us which line is #18 - I suppose that your 
snippet of code is part of bigger file?



-- 
Ondrej Par
Internet Securities
Software Engineer
e-mail: [EMAIL PROTECTED]
Phone: +420 2 222 543 45 ext. 112

Reply via email to