Re: Issues with subroutines and unbless references

Torsten Förtsch <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
On Tuesday 22 June 2010 12:01:39 Winfried Neessen wrote:
> I have a subroutine "handler" where I import the HTTP object from mod_perl 
> via: my $r = shift;
> This works well and as expected. But if I wanna use that object later on
>  in  a different
> subroutine, I get the following error message everytime I try to use the
>  $r  object in the
> subroutine: "argument is not a blessed reference (expecting an APR::Table 
> derived object)"
> 
> Here is a code example of what I've written:
> 
> ====================== begin code snippet =================================
...
>                 ## Extract value from HTTP object
>                 my $value = $r->headers_in( $head );

That's not the way to go. $r->headers_in returns an APR::Table object. This 
object holds all input headers. This object can then be used as tied hash or 
as described in L<APR::Table>.

In your case I'd do

  $r->headers_in->{$head}

or

  $r->headers_in->get($head)

The way you call headers_in means you want to set a new APR::Table object as 
input header collection. Hence the message.

...
> ====================== end code snippet =================================

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.