Syntax error in mod_perl but not in shell command

2008-05-29 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.


File::stat prototype mismatch in error log

2008-05-29 Thread John Gateley
Hi,

I'm using Apache2 and mod_perl
Server: Apache2/2.0.55 (Ubuntu) mod_ssl/2.0.55 OpenSSL/0.9.8a mod_perl/2.0.2 
Perl/v5.8.7

I am getting the following error in /var/log/apache2/error.log

Prototype mismatch: sub 
ModPerl::ROOT::ModPerl::PerlRun::home_yadb_httpd_cgi_2dbin_CoverArtSubmitFile_2ecgi::lstat:
 none vs ($) at /usr/share/perl/5.8/Exporter.pm line 65.
 at /home/yadb/httpd/cgi-bin/CoverArtSubmitFile.cgi line 13

CoverArtSubmitFile.cgi line 13 is:

use File::stat;

My subsequent calls to stat work fine, so it's not fatal:

my $StatObj = stat($TempFile-filename);
...
$StatObj-size
...

What does the error mean? And how can I get rid of it?

Thanks,

j
-- 
John Gateley [EMAIL PROTECTED]


Re: File::stat prototype mismatch in error log

2008-05-29 Thread Michael Peters
John Gateley wrote:

 Prototype mismatch: sub 
 ModPerl::ROOT::ModPerl::PerlRun::home_yadb_httpd_cgi_2dbin_CoverArtSubmitFile_2ecgi::lstat:
  none vs ($) at /usr/share/perl/5.8/Exporter.pm line 65.
  at /home/yadb/httpd/cgi-bin/CoverArtSubmitFile.cgi line 13
 
 CoverArtSubmitFile.cgi line 13 is:
 
 use File::stat;

So by default it's trying to override the built-in stat() function. Seems to be
conflicting. Overriding built-in's usually not a good idea.

 My subsequent calls to stat work fine, so it's not fatal:
 
 my $StatObj = stat($TempFile-filename);

Seems strange the you're using File::stat because it provides object oriented
access to that information, yet you're calling it as a function, not a
namespaced method. Try replacing that with (notice my non-use of CamelCase :)

  my $stat_obj = File::stat-new($temp_file-filename);

-- 
Michael Peters
Plus Three, LP



Re: File::stat prototype mismatch in error log

2008-05-29 Thread John Gateley
On Thu, 29 May 2008 14:33:54 -0400
Michael Peters [EMAIL PROTECTED] wrote:

 John Gateley wrote:
 
  use File::stat;
 
 So by default it's trying to override the built-in stat() function. Seems to 
 be
 conflicting. Overriding built-in's usually not a good idea.

Thanks - I changed it to use File::stat () so the built-in
wasn't overridden, and then the call to File::stat::stat(...)
and that fixed it.

 Try replacing that with (notice my non-use of CamelCase :)
 
   my $stat_obj = File::stat-new($temp_file-filename);

You say KA-mul, I say kah-MEL   :)

Thanks again...

j
-- 
John Gateley [EMAIL PROTECTED]


Re: Trouble with mod_perl, Archive::Zip and taint mode

2008-05-29 Thread Roberto C . Sánchez
On Tue, May 27, 2008 at 05:48:14PM -0400, Perrin Harkins wrote:
 On Sun, May 25, 2008 at 3:45 PM, Roberto C. Sánchez
  [Sun May 25 08:57:35 2008] [error] [asp] [11570] [error] error executing
  code for include /var/www/templates/Photo_page_edit.tmpl: Insecure
  dependency in open while running setgid at /usr/lib/perl/5.8/IO/File.pm
  line 70. -- ; compiled to SCALAR(0x91f6f24) at
  /usr/share/perl5/Apache/ASP/Response.pm line 844. -- ,
  /usr/share/perl5/Apache/ASP.pm line 1521
 
 You may be seeing the same problem that these people had:
 http://mail-archives.apache.org/mod_mbox/perl-modperl/200705.mbox/[EMAIL 
 PROTECTED]
 
 If so, upgrading to Perl 5.8.8+ and mod_perl 2.0.3+ will probably fix it.
 
That was it.  Etch already has Perl 5.8.8, but only mod_perl 2.0.2.
Updating to 2.0.4 cause that particular error to go away.  Of course I
have a different one now, but I am working on tracking it down.

  P.S. The server running this site is Debian Etch, so unfortunately, I
  cannot use Archive::Extract which is included in Perl 5.10.0.
 
 Just because it's not part of the core perl libs doesn't mean you
 can't install it.  This problem is probably fixable by upgrading Perl
 or mod_perl though.
 
Of course, except that if I install it, as soon as I upgrade the server
to the next Debian release, I will have a conflict.  That is why I was
trying to avoid installing it out of band, so to speak.

Thanks for the tip on the mailing list thread.

Regards,

-Roberto

-- 
Roberto C. Sánchez
http://people.connexer.com/~roberto
http://www.connexer.com


signature.asc
Description: Digital signature