[Catalyst] "Use of uninitialized value $buffer" error

Jesse Sheidlower jester at panix.com
Fri Jun 26 15:31:04 GMT 2009

On Mon, Jun 22, 2009 at 10:18:40AM +0100, Merlyn Kline wrote:
> > I'm getting an error that looks like:
> >
> > Use of uninitialized value $buffer in concatenation (.) or
> > string at /usr/share/perl5/Catalyst/Engine/CGI.pm line 220.
> Deep in my job list I have some notes surrounding this issue saying that I
> need to investigate further and possibly submit a patch or two.
> Unfortunately these notes (a) refer to an old version of Catalyst using
> FastCGI and (b) turn out not to be quite as lucid as I'd recalled them
> being. Basically, though, the obvious proximal cause of this would be
> calling the write method with no parameter. This might seem an odd thing to
> do but might be as a result of a loop writing something in chunks and
> getting an empty chunk at the end or, as in my case, might be an attempt to
> work around a related problem where the simple concatenation of the buffer
> to the headers (as in the code you cited, below) causes problems because the
> headers are not UTF8 encoded and the buffer is, so perl tries to fix the
> encoding and ends up with the wrong thing - calling write() with no
> parameters (or, in later bodges, an empty string) fixes this by flushing the
> headers into the output stream before the buffer is concatenated to them.
> Hope this is a useful clue.

I'm afraid this isn't too helpful for me at least; in this
case I'm just an end user, not doing anything fancy here, so
if there's a problem with buffer manipulation, I don't think
it's because of something I'm doing.


Jesse Sheidlower

> > ---
> > around write => sub {
> >     my $orig = shift;
> >     my ( $self, $c, $buffer ) = @_;
> >
> >     # Prepend the headers if they have not yet been sent
> >     if ( $self->_has_header_buf ) {
> >         $buffer = $self->_clear_header_buf . $buffer;
> >     }
> >
> >     return $self->$orig( $c, $buffer );
> > };
> > ---

More information about the Catalyst mailing list