Re: print print "Hello" - returns different values when executed from shell and mod-perl

[prev] [thread] [next] [Date index for 2004/11/19]

From: Stas Bekman
Subject: Re: print print "Hello" - returns different values when executed from shell and mod-perl
Date: 06:10 on 19 Nov 2004
Rathna N wrote:
> Hi,
> I'm new to Apache/mod-perl. I hope I'm asking this question in the right forum.
> 
> When I executed a script having " print print "Hello"; " at shell, it
> returns "Hello1",
> but when I executed thru mod-perl it returns "Hello5".
> 
> CODE SNIPPET:
> print "Content-type: text/html\n\n"; 
> print (print "hello");
> 
> 
> why is the return value of print is different ?

Guessing that you are using modperl 2.0:
print in mod_perl 2.0 is really $r->print (and implemented via perltie on 
STDOUT). It returns the number of bytes buffered/sent, not the success or 
failure. If there is an error it'll croak, so there is no need to check 
the return value.
http://perl.apache.org/docs/2.0/api/Apache/RequestIO.html#C_print_

I didn't check mod_perl 1.0, but it's probably similar.

In the future when you ask questions here, please first read:
http://perl.apache.org/bugs/ and save us the guessing part. Thank you.

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

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Re: print print "Hello" - returns different values when executed from shell and mod-perl
Stas Bekman 06:10 on 19 Nov 2004

Generated at 11:27 on 21 Dec 2004 by mariachi v0.52