To answer your second question first, a CHUNK is ( in this case ) a line 
from a file.  The word chunk is used simply because what constitutes a 
line can frequently be changed - I have a bad habit of toying with the 
input record separator.

The warnings are not directly prohibiting execution.  At a guess, you have 
blank lines in your file.  The split returns (\n,undef), and by chomping 
$input, you remove the \n.  Which, I believe, also causes $input to become 
undef.

Hth,
  Mik
--- 
Mik Firestone
Pinky, are you pondering what I am pondering?
Well, I think so Brain, but if we didn't have ears, we would look just 
like weasels.




Ondrej Par <[EMAIL PROTECTED]>
06/07/01 11:13 AM

 
        To:     Peter Cline <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
        cc: 
        Subject:        Re: Need help interpreting a warning

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