--- "J. Alejandro Ceballos Z." <[EMAIL PROTECTED]> wrote:
> I made a CGI that must send a piece of code to screen, otherwise,
> must 
> return a redirect command (is a banner CGI)
> 
> What it is stange to me is that the construction:
> 
> # ....blah, blah above
> #
> # Returns code or redirect to the page
> print ($str_codetoreturn)
>     ? $cgi_this->header().$str_codetoreturn
>     : $cgi_this->redirect(-uri=>$str_redirecto);
> #
> # end of cgi
> 
> sends a "premature end of headers" error; but:

That's because the code, while valid syntax, is not doing what you
want.  The ternary operator is switching basssed on the return value of
the print statement, not on the value of $str_codetoreturn.  The
following should illustrate:

  perl -le 'print (42) ? "foo" : "bar"'
  42

That can be fixed by moving the right parenthesis to encompass the
expression you wish to evaluate:

  perl -le 'print (42 ? "foo" : "bar")'
  foo

Cheers,
Ovid

-- 
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to