Mailing List Archive

Method Handler
(Half-comment, half-doc change below)

I don't have a specific patch (yet), but as I just used method handlers for
the first time, studying from the v1 guide, I thought I should point out
that the guide does not go out of it's way to remind the poor users about
mod_perl's namespace mess. Example:

If in mod_perl_start.pl you declare:
$obj=Object->new;

or even

our $obj=Object->new;

(in httpd.conf)

<Perl>
warn "Object is ".ref($obj);
</Perl>

$obj will be out of scope. Rememdy for non-experts is: ALWAYS FULLY DECLARE
OBJECTS TO BE USED WITH METHOD HANDLERS

Solution:

(mod_perl_start.pl).

$PermanentNamespace::Obj=Object->new

After writing all that, it occured to me that a better alternative is in one
of the existing examples on the page which use $My::Obj, simply specifically
point out that the "My::" prefix is for a namespace and should not be
confused with my $obj

Issac


---------------------------------------------------------------------
To unsubscribe, e-mail: docs-dev-unsubscribe@perl.apache.org
For additional commands, e-mail: docs-dev-help@perl.apache.org
Re: Method Handler [ In reply to ]
Issac Goldstand wrote:
> (Half-comment, half-doc change below)
>
> I don't have a specific patch (yet), but as I just used method handlers for
> the first time, studying from the v1 guide, I thought I should point out
> that the guide does not go out of it's way to remind the poor users about
> mod_perl's namespace mess. Example:
>
> If in mod_perl_start.pl you declare:
> $obj=Object->new;
>
> or even
>
> our $obj=Object->new;
>
> (in httpd.conf)
>
> <Perl>
> warn "Object is ".ref($obj);
> </Perl>
>
> $obj will be out of scope. Rememdy for non-experts is: ALWAYS FULLY DECLARE
> OBJECTS TO BE USED WITH METHOD HANDLERS
>
> Solution:
>
> (mod_perl_start.pl).
>
> $PermanentNamespace::Obj=Object->new
>
> After writing all that, it occured to me that a better alternative is in one
> of the existing examples on the page which use $My::Obj, simply specifically
> point out that the "My::" prefix is for a namespace and should not be
> confused with my $obj

Good points Issac, patches are very welcome ;)

__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: docs-dev-unsubscribe@perl.apache.org
For additional commands, e-mail: docs-dev-help@perl.apache.org