On Thu, Mar 26, 2009 at 05:45:12PM -0500, Mark Copper wrote:
> On Sun, Mar 22, 2009 at 11:04:15PM -0500, Dave Rolsky wrote:
> > On Sun, 22 Mar 2009, Mark Copper wrote:
> > 
> > > Begging your forebearance with this silly question.  It seems to be
> > > related to hanging Apache processes.
> > >
> > > I am occasionally getting the warning:
> > >   Use of uninitialized value in concatenation (.) or string at
> > >   /usr/share/perl5/HTML/Mason/Request.pm line 1191.
> > >
> > > On my Debian install, line 1191 is the concatenation line in the print
> > > sub:
> > >
> > > sub print
> > > {
> > >    my $self = shift;
> > >
> > >    # $self->{top_stack} is always defined _except_ in the case of a
> > >    # call to print inside a start-/end-request plugin.
> > >    my $bufref =
> > >        ( defined $self->{top_stack}
> > >          ? $self->{top_stack}->[STACK_BUFFER]
> > >          : \$self->{request_buffer}
> > >        );
> > >
> > >    # use 'if defined' for maximum efficiency; grep creates a list.
> > >    for ( @_ ) {
> > >        $$bufref .= $_ if defined;  # this is line 1191
> > >    }
> > >
> > >    $self->flush_buffer if $self->{autoflush};
> > > }
> > >
> > > My question: what can possibly be in @_ that satisfies the conditional
> > > "if defined" and still sets off the "unitialized value" warning?
> > 
> > If $$bufref itself is not defined, that could do it.
> > 
> > I'm not sure how that would happen in just rare cases. I'd think if it 
> > happened it would happen often. I'd also think it would happen for 
> > everyone else.
> > 
> > 
> > -dave
> 
> This had me a bit flummoxed.  On one hand, $$bufref is frequently not
> defined, but the "uninitialized value" warning is quite rare.  And on the 
> other, I didn't know the LHS of a concatenation could trigger the 
> warning:
> 
> $ perl -we'my $a; my $b=\$a; my $c="Help!";$$b .= $c; print "$a\n"'
> Help!
> $ 
> 
> and certainly not the RHS:
> 
> $ perl -we'my $a="Help!"; my $b; $a .= $b if defined $b; print "$a\n"'
> Help!
> $
> 
> I just never thought of checking if both were not defined:
> 
> $ perl -we'my $a; my $b; $a .= $b if defined $b; print "$a\n"'
> Use of uninitialized value in concatenation (.) or string at -e line 1.
> 
> $
> 
> Oh my...
> 
> Mark

There is actually a moral to this story for people at the base of the
learning curve like me.

The diagnostics pragma didn't provide new info but did provide a bit of
advice: the warning may actually be inherited from the caller.

Helpful info was obtained using Carp as warnings handler, cf. Practical
mod_perl (example 21-1 in my copy but available on-line).

With the guilty component isolated, judiciously placed warnings isolated
the problem.

Mark

------------------------------------------------------------------------------
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to