You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Ricky <ri...@virtual-map.com> on 2002/04/30 09:09:11 UTC
PerlRun problem: can't find method "uri"?
Hi All,
I am trying to porting mod_cgi script to mod_perl script because
the mod_cgi script don't run correctly under mod_perl.
When running under apache::registry, the script show wrong result.
When running under apache::perlrun, the script sometimes crash.
In error_log show :
"can't locate object method "uri" via package "Apache::perlrun"
In mod_perl manual said that the script usually run in apache::perlrun
widthout change but not in my script.
And I can't add "use strict" because it will crash the script immediatelly.
In error_log show :
"Variable "%in" is not imported at /home/httpd/html/scdf/scdf.plx line 174."
"Global symbol "$sth" requires explicit package name at
/home/httpd/html/scdf/scdf.plx line 171."
Our company planning to move from Perl/CGI to better/faster technology.
Currently research about mod_perl.
Is it a good decision try to move to mod_perl because the implementation time
is slow.
Is there any other tech that easier/more faster than mod_perl?
How about PHP or JSP?
Best Regards,
Ricky
Re: PerlRun problem: can't find method "uri"?
Posted by Per Einar Ellefsen <pe...@skynet.be>.
At 08:51 01.05.2002, Ricky wrote:
>On Tuesday 30 April 2002 03:44 pm, you wrote:
> > You better fix these errors, and keep 'use strict' in place. Then
> > PerlRun should work without any problems in most cases. If after fixing
> > those problems you still have problems, come back with your relevant
> > questions again.
>
> > It's a good idea to have your code running under 'use strict' no matter
> > if you use mod_perl or not. This will save you a lot of grief in a long
> > run.
>---
>I agree with Stas that if you fix the problems with your script running
>under "strict" this will most likely go away.
>---
>
>I see, thank you for the suggestion.
>There are so many error in the script, usually related with global variable.
>I change/add this in the script.
>
>global variable: use var qw($myvar $in);
You still need to watch out for their use; even if they're declared as
global and pass "use strict" doesn't mean they won't create the subtleties
related to global variables in mod_perl. I strongly advise you to read the
mod_perl Guide at
http://perl.apache.org/preview/modperl-docs/dst_html/docs/1.0/guide/index.html
and for your problems here the "Perl Reference" and "CGI to mod_perl
porting" guidelines.
>local variable: my $myvar;
>
>I still don't know how to change this variable:
>
>local($long, $lat, $level);
>
>[error] PerlRun: 'Global symbol "$long" requires explicit package name at
>/home/httpd/...
You should be able to declare them as my(), except if you're doing:
{
local $var = 'something';
subroutine();
}
and then:
sub subroutine {
print $var;
}
In that case you should probably be moving to :
{
my $var = 'something';
subroutine($var);
}
sub subroutine {
my $var = shift;
print $var;
}
Which is generally better and will work the best, without surprises. Again,
see the references I pointed you to above, they are really good.
> > It depends on your definition of "easier".
> >
> > Easier==sloppier: better stay away from mod_perl.
> > Easier==more flexible: go with mod_perl.
> >
> > As for the speed, I doubt you will find something *significantly* faster
> > than mod_perl. Assuming that you learn how to get the most our of mod_perl.
>---
>It will be much faster to fix your CGI scripts so they run under
>mod_perl than to re-write them in PHP or JSP.
>---
>I see.
>Well, we will try to porting 1 big script to see the speed different.
>Any help would be great
If you want something, you have to pay for it with your time :) You won't
get free speed without good coding. Anyway, we're ready to help out with
any questions not answered in the Guide.
--
Per Einar Ellefsen
per.einar@skynet.be
Re: PerlRun problem: can't find method "uri"?
Posted by Ricky <ri...@virtual-map.com>.
On Tuesday 30 April 2002 03:44 pm, you wrote:
> You better fix these errors, and keep 'use strict' in place. Then
> PerlRun should work without any problems in most cases. If after fixing
> those problems you still have problems, come back with your relevant
> questions again.
> It's a good idea to have your code running under 'use strict' no matter
> if you use mod_perl or not. This will save you a lot of grief in a long
> run.
---
I agree with Stas that if you fix the problems with your script running
under "strict" this will most likely go away.
---
I see, thank you for the suggestion.
There are so many error in the script, usually related with global variable.
I change/add this in the script.
global variable: use var qw($myvar $in);
local variable: my $myvar;
I still don't know how to change this variable:
local($long, $lat, $level);
[error] PerlRun: 'Global symbol "$long" requires explicit package name at
/home/httpd/...
> It depends on your definition of "easier".
>
> Easier==sloppier: better stay away from mod_perl.
> Easier==more flexible: go with mod_perl.
>
> As for the speed, I doubt you will find something *significantly* faster
> than mod_perl. Assuming that you learn how to get the most our of mod_perl.
---
It will be much faster to fix your CGI scripts so they run under
mod_perl than to re-write them in PHP or JSP.
---
I see.
Well, we will try to porting 1 big script to see the speed different.
Any help would be great
> [p.s. please make sure you reply back to the list!]
Ok :)
Best Regards,
Ricky
Re: PerlRun problem: can't find method "uri"?
Posted by Stas Bekman <st...@stason.org>.
Ricky wrote:
> Hi All,
> I am trying to porting mod_cgi script to mod_perl script because
> the mod_cgi script don't run correctly under mod_perl.
>
> When running under apache::registry, the script show wrong result.
what do you mean, wrong results. Have you read
http://perl.apache.org/preview/modperl-docs/dst_html/docs/1.0/guide/porting.html
> When running under apache::perlrun, the script sometimes crash.
> In error_log show :
> "can't locate object method "uri" via package "Apache::perlrun"
>
> In mod_perl manual said that the script usually run in apache::perlrun
> widthout change but not in my script.
>
> And I can't add "use strict" because it will crash the script immediatelly.
> In error_log show :
> "Variable "%in" is not imported at /home/httpd/html/scdf/scdf.plx line 174."
> "Global symbol "$sth" requires explicit package name at
> /home/httpd/html/scdf/scdf.plx line 171."
You better fix these errors, and keep 'use strict' in place. Then
PerlRun should work without any problems in most cases. If after fixing
those problems you still have problems, come back with your relevant
questions again.
It's a good idea to have your code running under 'use strict' no matter
if you use mod_perl or not. This will save you a lot of grief in a long run.
> Our company planning to move from Perl/CGI to better/faster technology.
> Currently research about mod_perl.
> Is it a good decision try to move to mod_perl because the implementation time
> is slow.
> Is there any other tech that easier/more faster than mod_perl?
> How about PHP or JSP?
It depends on your definition of "easier".
Easier==sloppier: better stay away from mod_perl.
Easier==more flexible: go with mod_perl.
As for the speed, I doubt you will find something *significantly* faster
than mod_perl. Assuming that you learn how to get the most our of mod_perl.
[p.s. please make sure you reply back to the list!]
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Re: PerlRun problem: can't find method "uri"?
Posted by Perrin Harkins <pe...@elem.com>.
Ricky wrote:
> When running under apache::perlrun, the script sometimes crash.
I agree with Stas that if you fix the problems with your script running
under "strict" this will most likely go away.
> In mod_perl manual said that the script usually run in apache::perlrun
> widthout change but not in my script.
One thing that often causes problems is old Perl4-style library files.
If you have functions that you load from some .pl files which have no
package name and are pulled into the main namespace, you should change
them into real Perl5-style modules. There are lots of reasons you
should fix this; mod_perl is just one of them.
> And I can't add "use strict" because it will crash the script immediatelly.
> In error_log show :
> "Variable "%in" is not imported at /home/httpd/html/scdf/scdf.plx line 174."
> "Global symbol "$sth" requires explicit package name at
> /home/httpd/html/scdf/scdf.plx line 171."
If you've read the documentation and you still need help understanding
how to program with the "strict" pragma, I suggest looking on
http://perlmonks.org/.
> Is it a good decision try to move to mod_perl because the implementation time
> is slow.
> Is there any other tech that easier/more faster than mod_perl?
> How about PHP or JSP?
It will be much faster to fix your CGI scripts so they run under
mod_perl than to re-write them in PHP or JSP.
- Perrin
Re: PerlRun problem: can't find method "uri"?
Posted by Per Einar Ellefsen <pe...@skynet.be>.
At 09:09 30.04.2002, Ricky wrote:
>When running under apache::perlrun, the script sometimes crash.
>In error_log show :
>"can't locate object method "uri" via package "Apache::perlrun"
This got me wondering: are you specifying Apache::PerlRun in any
configuration or Apache::perlrun? Please remember that Perl packages and
modules are case-sensitive, so Apache::PerlRun (which is the correct one)
is different from Apache::perlrun.
>Currently research about mod_perl.
>Is it a good decision try to move to mod_perl because the implementation time
>is slow.
>Is there any other tech that easier/more faster than mod_perl?
>How about PHP or JSP?
Well, if you don't want to change your scripts, it's most likely that
implementation in PHP or JSP will be a lot slower: you'll have to find
competent people in those fields, learn the technology, etc. While with a
few fixes to your current code you should be able to run it under mod_perl.
As for PHP and JSP, they take completely different approaches (code-in-HTML
at the most basic level), which are mostly considered to be a bad thing (as
they mix logic and presentation). Of course, these technologies have their
own advantages, but it will not be easier to work with them than with mod_perl.
--
Per Einar Ellefsen
per.einar@skynet.be