At 05:13 PM 6/7/01 +0200, Ondrej Par wrote:
>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.
> >
> > 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.
This one seems to.
>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.
The value is defined and passed as follows
my $configFile = "lib/request.conf";
my %conf = ();
my $varValueSep = '==';
my $confComment = '#';
processConfFile (\$configFile, \%conf, \$varValueSep, \$confComment);
>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?
Line eighteen is marked in the code above.
Thanks
Peter Cline
Inet Developer
New York Times Digital