APM: Null fields and 100% processor

Goldilox Goldilox at teachnet.edb.utexas.edu
Fri Apr 4 00:08:09 CST 2003


Hate to answer Jeopardy style - just wanted to say I had been trying all kinds
of things - but I was seeing if the warning generated by the print "Before:.."
would disappear in the print "After:.." statement. I had to watch for the
warnings since they were in odd places I wasn't expecting.

Thanks again to everyone for their patience with me.

Rhett

msouth at fulcrum.org writes:
>>From: "Goldilox" <Goldilox at teachnet.edb.utexas.edu>
>>Date: Tue, 01 Apr 2003 15:51:53 -0600
>>but I thought I was being dumb because defined is only for arrays and I am
>>dealing with a scalar variable - so I didn't mention it here. 
>
>Actually, the use of defined() on arrays is deprecated (which I didn't 
>know until I looked at 'perldoc -f defined').  defined() is good for
>scalars as well as subroutines and I can't remember what else.
>
>I'm not sure how literally to take your code, but, if I'm reading it right,
>nothing you do will fix the problem until you move that print statement
>down below the 'fix the problem' part:
>
>	while(my @newdata = $newsth->fetchrow_array()){
>
>		# this print statement puts a potentionally uninitialized
>		# variable in string, generating a warning 
>		print "Before: $newdata[1] - $newdata[2]\n";
>
>		# here is where you are trying to define potential undefs
>		$newdata[1] = "N/A" if $newdata[1] eq "";
>
>If you do something like this:
>
>	while(my @newdata = $newsth->fetchrow_array()){
>
>		# every undef in @newdata will get set to "N/A" here
>		for (@newdata) { $_ = 'N/A' unless defined $_ };
>
>		print "after: $newdata[1] - $newdata[2]\n";
>
>		...
>	}
>
>you won't be interpolating $newdata[1] into the string until after
>you have done the check/correction for undefs.
>
>It looks to me like you might have tried more than one thing that
>would have fixed your problem, but you were always doing it _after_
>you had already used the undef variables in a print(), which generates
>the warning you say you are getting.
>
>mike
>
>>It gave me the
>>same warnings "uninitialized variable in string or concatenation".
>>
>>Rhett
>_______________________________________________
>Austin mailing list
>Austin at mail.pm.org
>http://mail.pm.org/mailman/listinfo/austin





More information about the Austin mailing list