[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] runmode return scalar reference ?


--- Michael Peters <suppressed> wrote:
> 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.
> 

good eye. I was mainly looking for it in the run() doc.

> > 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.
>

argh, thanks for pointing out to me. 
 
> -- 
> Michael Peters
> Developer
> Plus Three, LP
> 
> 

James.


       
____________________________________________________________________________________Got a little couch potato? 
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz 

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


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.