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


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: Re: AW: AW: Use of uninitialized valued in concatenation....

2003-08-23 Thread Marcel Greter

-CUT--
my $val=$_||'NULL'; print qq($val);
-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($_); # 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: 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($_); # 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($_) if $_;
-CUT--

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

-CUT--
my $val=$_||'NULL'; print qq($val);
-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



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

2003-08-23 Thread B. Fongo





Oh yes I did. I always try my script on the command line to ensure the
syntax are ok before running them on the web server with  mod_perl.  So
the error has to do with mod_perl. Perhaps you may want to take a look
of some examples:

I have a file (output_tab.pm) that I use to generate tables dynamically.
Even though it serves its purpose, it goes on generating this error:

“Script_name.pl: Use of uninitialized value in concatenation (.) or
string at output_tab.pm line 42”.

I went through this section of mod_perl docs und thought I’ve understood
it, but I can’t feature out the error. I’ll appreciate any help.

Below is  my module and a script that triggers such error.

#
 output_tab.pm


#-
# Modulname: output_tab.pm
#-
use strict;
package output_tab;
use vars qw(@ISA @EXPORT);
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(output_tab);
use db_Verbindungen;




sub output_tab{
   
   my ($dbh,$abfrage,$columnspan, $sth,@table_head,@table_data);
   ($abfrage, @table_head) = @_;
   $columnspan = @table_head;
   print qq();
   print qq();

   foreach (@table_head){
  print qq($_);

   }
   print qq();

   # Erbnisse Anzeigen
   $dbh = db_Verbindungen;
   $sth = $dbh->prepare($abfrage);
   $sth->execute();
   print qq();
   while(@table_data = $sth->fetchrow_array){
  #my $table_data;
  foreach (@table_data)
  {
   
   print qq($_); # Here is line 42
  }
   print qq();
  }
  print qq( );
  print qq();
  $sth->finish();
  $dbh->disconnect();   
}
1;
   
 
###


#!/usr/bin/perl -w

#
#Script: pakete_auflisten.pl
#=

use strict;
use db_Verbindungen;
use gui;
use output_tab;


my ($dbh,$abfrage,@table_head);
$abfrage = ('SELECT Gruppe, Paketname, Auftragsdatum, Status,
Statusmeldung FROM Gruppen_Software ORDER BY Auftragsdatum DESC'); 
@table_head = qw(Gruppe Paketname Auftragsdatum Status Statusmeldung);

# Aufruf der Methode top() des gui.pm Moduls.
top('Paketliste');

# At this stage i call the method output_tab with two arguements.
output_tab($abfrage,@table_head);

# Aufruf der Methode footer() des gui.pm Moduls.
footer();


#== ENDE==




Babs
























-Ursprüngliche Nachricht-
Von: Sreeji K Das [mailto:[EMAIL PROTECTED] 
Gesendet: Samstag, 23. August 2003 11:10
An: B. Fongo; 'Perrin Harkins'; [EMAIL PROTECTED]
Betreff: Re: AW: Use of uninitialized valued in concatenation

Did u check what's in line # 42 ? If u run the same
script with same params as stand-alone, do u see the
warning ?

Sreeji
 --- "B. Fongo" <[EMAIL PROTECTED]> wrote: > It is not a
standard perl error message. I went
> through mod_perl doc at
>
http://perl.apache.org/docs/general/perl_reference/perl_reference.html#T
> racing_Warnings_Reports
> 
> and understand that, the error message appear if one
> fails to pass a
> value to a subroutine before using. Looking through
> my codes, you may
> have noticed that, I did pass 2 arguments to the
> subroutine.
> 
>  
> 
> -Ursprüngliche Nachricht-
> Von: Perrin Harkins [mailto:[EMAIL PROTECTED] 
> Gesendet: Samstag, 23. August 2003 00:10
> An: B. Fongo
> Cc: [EMAIL PROTECTED]
> Betreff: Re: Use of uninitialized valued in
> concatenation
> 
> On Fri, 2003-08-22 at 17:23, B. Fongo wrote:
> > I have a file (output_tab.pm) that I use to
> generate tables
> > dynamically. Even though it serves its purpose, it
> goes on generating
> > this error:
> > 
> > “Script_name.pl: Use of uninitialized value in
> concatenation (.) or
> > string at output_tab.pm line 42”.
> 
> This is a standard perl error message.  It is not
> related to mod_perl. 
> You can look in the perldiag man page for a more
> complete explanation.
> 
> - Perrin


Want to chat instantly with your online friends?  Get the FREE Yahoo!
Messenger http://uk.messenger.yahoo.com/




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