James.Q.L wrote:
> hi,
> 
> poking through C::A src code and i noticed that one can return a scalar 
> reference as output from a
> runmode. as indicated by the followying lines from run subroutine.
> 
> # Support scalar-ref for body return
> my $bodyref = (ref($body) eq 'SCALAR') ? $body : \$body;
> ....
> # Build up total output
> my $output  = $headers.$$bodyref;
> .....
> return $output;
> 
> C::A doc doesn't mention it and i have never seen ppl doing stuff like 

It actually does mention it, but only briefly. In the documentation for
"run_modes()" it says:

  The run mode method may return its block of text as a scalar or a scalar-ref.

I agree that it should get a bigger mention than that. For instance, the "USAGE
EXAMPLE" has this:

  Instead, all output is returned as a scalar.

This could be expanded to say something about scalar references too. And the
current mention could be expanded to mention something about the reasons why
you'd do one over the other.

> but it seems to be a good thing to do,especially in mod_perl. my question 
> would be.. is this a
> well-known behaviour?

It's pretty well known. In fact, the example you cite of not seeing "return
\$self->tt_process()" is because CGI::Application::Plugin::TT's tt_process()
already returns a scalar reference.

-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to