CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: mod_perl:
How to convert your scripts to mod_perl

 



yapp
User

Mar 1, 2002, 7:16 AM

Post #1 of 13 (15893 views)
How to convert your scripts to mod_perl Can't Post

Well?

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


Paul
Enthusiast

Mar 1, 2002, 8:26 AM

Post #2 of 13 (15885 views)
Re: [yapp] How to convert your scripts to mod_perl [In reply to] Can't Post

http://perl.apache.org/guide/

Always use strict and warnings :)


mire
Novice

Mar 1, 2002, 7:26 PM

Post #3 of 13 (15882 views)
Re: [RedRum] How to convert your scripts to mod_perl [In reply to] Can't Post

man cgi_to_mod_perl
man Apache::Registry
man Apache::PerlRun


_______________________________________________

Best regards,

Miroslav Madzarevic, Senior Perl Programmer
perl@modperldev.com
Mod Perl Development  - http://www.modperldev.com
Telephone: +381 64 1193 501
ICQ: 15880893
jamph


yapp
User

Mar 3, 2002, 11:59 AM

Post #4 of 13 (15875 views)
Re: [RedRum] How to convert your scripts to mod_perl [In reply to] Can't Post

Thanks, I'll read through it.

Are there some important notes you can reveal already now?

btw, I haven't got the cgi_to_mod_perl manpage! Where can I get it?

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


Cure
User

Jun 8, 2002, 9:52 AM

Post #5 of 13 (15787 views)
Re: [yapp] How to convert your scripts to mod_perl [In reply to] Can't Post

You want to use the Apache::Registry module....

http://perl.apache.org/dist/cgi_to_mod_perl.html





Cure


yapp
User

Jun 9, 2002, 3:23 AM

Post #6 of 13 (15784 views)
Re: [Cure] How to convert your scripts to mod_perl [In reply to] Can't Post

Am I right here??

- Can't read from STDIN???

- Can't print to STDOUT??

- Use a special CGI::Switch sometimes?

Oh boy! It's even thougher then I thought... Well, my forum is being converted into OO (for version 2) right now, so that will be easier to convert.. But still, I'm confused.. I never thought it would be so difficult... Because if I ever get that mod_perl in my program, it would be a very cool. Cool

In the next version of my forum, I eliminated almost all standard modules.. Especially CGI.pm ... I'm frustrated of what that module loads... Defaultly it even loads 'overload.pm', which is only used for multipart-data (file uploads) Frown etc etc.. I think there is too much overhead. (also elimitated vars.pm... that's indirectly loading a lot too) The only think I have lefty is strict now. Smile

Fortunately, I have been using strict and -w from the beginning... That's the biggest culture shock for mod_perl newbies I guess...

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


Revelation
Novice

Jun 11, 2002, 10:09 AM

Post #7 of 13 (15780 views)
Re: [yapp] How to convert your scripts to mod_perl [In reply to] Can't Post

Some other things:

No __DATA__ Flags at the end of your script, or __END__ flags, either I believe.

Mod_Perl is a stricter "language" than perl, which involves making sure we don't have memory leaks, etc. You'll get them even if you are strict and warnings compliant.

Modules are *good*, modular coding attests to your abilities, in now way does it detract from them. A well defined object orriented structure in your modules will make your script clean and simple, it will also make modification heaps easier.

If you're not using CGI;, then I hope you're using the appropriate Apache modules.

Still on the subject of modules, I'd recomend reading: http://perl.apache.org/tuning/#BASIC_CONFIGURATION Loading modules onto the http processes will make your scripts damn quick.

http://perl.apache.org/dist/cgi_to_mod_perl.html has some other stuff.


yapp
User

Jun 12, 2002, 2:31 PM

Post #8 of 13 (15775 views)
Re: [Revelation] How to convert your scripts to mod_perl [In reply to] Can't Post

Oh... the __END__ tokens are only used in the modules, to stop perl reading through the included pod documentation.

Also, I need to read the docs carefully about some "re-initializing" subroutines. Some variabels need to be reset after running.

Also I wonder: My next version reads in a sortof ini-files containing the settings. That's because I think it's easier to edit, and doesn't make end-users cause Perl errors. The settings read are filled into a hash, so they can be re-used by all other modules easier.

I wonder, when should I empty that hash? Every time? When I detect the file has changed? (and how do I check that?) This saves memory, but generates more IO.

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


Paul
Enthusiast

Jul 15, 2002, 5:13 PM

Post #9 of 13 (15640 views)
Re: [yapp] How to convert your scripts to mod_perl [In reply to] Can't Post

>>
Oh... the __END__ tokens are only used in the modules, to stop perl reading through the included pod documentation.
<<

Using __END__ with mod_perl is ok.

>>
Also, I need to read the docs carefully about some "re-initializing" subroutines. Some variabels need to be reset after running.
<<

Use END and DESTROY blocks in your modules to reset globals and try to clear out anything that may not be reset under mod_perl...you can add this code into your cgi script which will get executed on every request...eg...

Module->reset_env;


Revelation
Novice

Jul 15, 2002, 7:48 PM

Post #10 of 13 (15638 views)
Re: [RedRum] How to convert your scripts to mod_perl [In reply to] Can't Post

Paul, I was under the impression that __END__ tokens were not alright in mod_perl *scripts*, but were alright in handlers....

As you know scripts are converted into temp handlers some how (I'm not advanced enough to understand the process...) The script is then executed, but will get screwed up as __END__ will stop the last } to close the sub handler.... It's documented as well... so I'm pretty sure it's true.... ( Check my OO thread in intermediate...)


Paul
Enthusiast

Jul 16, 2002, 2:43 AM

Post #11 of 13 (15635 views)
Re: [Revelation] How to convert your scripts to mod_perl [In reply to] Can't Post

Sorry maybe I wasn't clear...it is ok to use them in modules that get loaded into mod_perl, otherwise as you say, __END__ will be put before } and you'll get syntax errors.


thebitch
User

Aug 9, 2002, 7:09 AM

Post #12 of 13 (15548 views)
Re: [yapp] How to convert your scripts to mod_perl [In reply to] Can't Post

I also suggest taking a look at mod_perl-2
ModPerl::Registry instead of Apache::Registry
and ModPerl::PerlRun


Cure
User

Nov 29, 2002, 8:58 AM

Post #13 of 13 (14956 views)
Re: [Revelation] How to convert your scripts to mod_perl [In reply to] Can't Post

This comes straight from the take23.org site ->

Simply put, mod_perl is a software package that embeds a Perl interpreter into the Apache HTTP server, giving the developer access to the Apache module API from within Perl. This allows you to build Apache module server extentions in Perl, rather than in C. Don't worry if this definition seems a bit like techo-babble at the moment. You will soon see what this description means, and how mod_perl can help you to create advanced, high-volume Web applications quickly and easily.



About the __EXIT__ and __DATA__ tokens -->



Apache::Registry scripts cannot contain __END__ or __DATA__ tokens.

Why? Because Apache::Registry scripts are being wrapped into a subroutine called handler



http://perl.apache.org/docs/1.0/guide/porting.html#__END___and___DATA___tokens





Cure

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives