Re: AW: AW: Use of uninitialized valued in concatenation....

2003-08-23 Thread Udo Rader
Am Sat, 23 Aug 2003 09:48:05 + schrieb B. Fongo:
   foreach (@table_data)
   {

print qq(td bgcolor='#d0d0d0'$_/td); # Here is line 42
   }

as Frank already pointed out, your trouble is the uninitialized $_ value
you have in line 42 (which is exactly what the warning tells you, BTW).

the reason for this is very probably that @table_data contains items
that have not been initialized (= they have no value, not even an
empty value assigned to them). @table_data is filled from
database, so _check your database_. I bet you will find null values in
here.

if you don't want to output anything if the database delivers such a null
value simply replace your line 42 with

-CUT--
print qq(td bgcolor='#d0d0d0'$_/td) if $_;
-CUT--

if you want to output an empty line for null values, then do as Frank
suggested:

-CUT--
my $val=$_||'NULL'; print qq(td DEFANGED_bgcolor=0#d0d0d0$val/td);
-CUT--

and no, this has definitively absolute nothing to do with mod_perl, thats
just expected and normal perl behaviour.

happy hacking

udo


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: Re: AW: AW: Use of uninitialized valued in concatenation....

2003-08-23 Thread Marcel Greter

-CUT--
my $val=$_||'NULL'; print qq(td DEFANGED_bgcolor=0#d0d0d0$val/td);
-CUT--
 

This is not a very good solution. You would also catch the case where $_ 
is 0, which may should not happen. You would better do

foreach (@table_data) {
$_ = defined $_ ? $_ : NULL;
print qq(td bgcolor='#d0d0d0'$_/td); # Here is line 42
}
Basically you also simply could use the warnings pragma within this sub :

no warnings uninitialized;

greets, Marcel



--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: Re: AW: AW: Use of uninitialized valued in concatenation....

2003-08-23 Thread Frank Maas
On Sat, Aug 23, 2003 at 01:55:03PM +0200, Marcel Greter wrote:
 
 This is not a very good solution. You would also catch the case where $_ 
 is 0, which may should not happen. You would better do

Yes... I always fall into that pithole. I think this is because I find
the 'defined(...) ? ... : ...' phrase is kinda ugly. Silly me, I know.

   $_ = defined $_ ? $_ : NULL;

Still... I don't know if I like toying around with $_. Especially since
you change the real array value (and not a copy) and this might cause
problems later on (should you use the values somewhere else as well).

But why are we talking about this on a mod_perl list. Sorry guys.

--Frank


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: AW: AW: Use of uninitialized valued in concatenation....

2003-08-23 Thread Stas Bekman
Frank Maas wrote:
On Sat, Aug 23, 2003 at 01:55:03PM +0200, Marcel Greter wrote:

This is not a very good solution. You would also catch the case where $_ 
is 0, which may should not happen. You would better do


Yes... I always fall into that pithole. I think this is because I find
the 'defined(...) ? ... : ...' phrase is kinda ugly. Silly me, I know.

	$_ = defined $_ ? $_ : NULL;
perl 5.9 has introduced a new operator //= to make it spiffy, so you'd write 
the above as:

  $_ //= NULL;

__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html