Syntax error in mod_perl but not in shell command

2008-05-28 Thread william
Hello, I am running this code

print "Content-type: text/html\n\n";

use Switch;
$t =1;

switch ($t) {
case 1  { print "number 1\n"; }
}

I have not problem running in shell command
[EMAIL PROTECTED]:/var/www/modperl$ perl test.pl
Content-type: text/html

number 1

But when I ran in mod_perl , I got error
[Thu May 29 14:48:16 2008] [error] syntax error at
/var/www/modperl/test.pl line 6, near ") {"\nNumber found where
operator expected at /var/www/modperl/test.pl line 7, near "case
1"\nsyntax error at /var/www/modperl/test.pl line 8, near "}\n}"\n


Thanks


Re: Syntax error in mod_perl but not in shell command

2008-05-29 Thread Michael A. Capone
I can reproduce this, exactly as he says below.  Some kind of 
incompatibility between mod_perl and the Switch module?


william wrote:


Hello, I am running this code

print "Content-type: text/html\n\n";

use Switch;
$t =1;

switch ($t) {
case 1  { print "number 1\n"; }
}

I have not problem running in shell command
[EMAIL PROTECTED]:/var/www/modperl$ perl test.pl
Content-type: text/html

number 1

But when I ran in mod_perl , I got error
[Thu May 29 14:48:16 2008] [error] syntax error at
/var/www/modperl/test.pl line 6, near ") {"\nNumber found where
operator expected at /var/www/modperl/test.pl line 7, near "case
1"\nsyntax error at /var/www/modperl/test.pl line 8, near "}\n}"\n


Thanks

 



--

-
   C  CableWholesale.com, Inc.
 _ CC   CCP.O. Box 11775 
|  CC   -- m  Pleasanton, CA 94588  
|  CC  888-212-8295o 
|_ CC   == c  1-888-212-8295 Phone   
   CC   CC  CableWholesale .  1-925-455-0808 Fax 
   C  www.cablewholesale.com 
-



Re: Syntax error in mod_perl but not in shell command

2008-05-29 Thread Michael Peters
Michael A. Capone wrote:
> I can reproduce this, exactly as he says below.  Some kind of
> incompatibility between mod_perl and the Switch module?

Switch is a source filter. source filters == evil. I've heard all kinds of
horror stories about using them under mod_perl.

If you really need that kind of a statement use Perl 5.10's given/when. Much
more powerful. Switch is really just syntax sugar for if/elseif/else.

-- 
Michael Peters
Plus Three, LP



Re: Syntax error in mod_perl but not in shell command

2008-05-29 Thread Heiko Jansen
As far as I understand it, mod_perl will eval{} the code it's going to
run and in the paragraph "Limitations" on
http://search.cpan.org/~rgarcia/Switch-2.13/Switch.pm
we're told that "Due to the way source filters work in Perl, you can't
use Switch inside an string eval.".

heiko



Re: Syntax error in mod_perl but not in shell command

2008-05-29 Thread william
On 5/30/08, Heiko Jansen <[EMAIL PROTECTED]> wrote:
> As far as I understand it, mod_perl will eval{} the code it's going to
>  run and in the paragraph "Limitations" on
>  http://search.cpan.org/~rgarcia/Switch-2.13/Switch.pm
>  we're told that "Due to the way source filters work in Perl, you can't
>  use Switch inside an string eval.".
>
>
>  heiko
>
>


Yeah, I love mod_perl but it's a little disappointing, because I guess
I would not longer assume that whatever that I can run in CGI, I can
run in mod_perl too. I have upgraded my perl to 5.10 now. Thanks.