Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs

Biz Resources
ERP Software
Computer Hardware
Data Backup Services


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us
PDA Phones & Cases
Desktop Computers
Memory Upgrades
Memory
Baby Photo Contest
Cell Phones
KVM Switches
Promotional Gifts
Car Donations
Logo Design
Phone Cards
Auto Insurance Quote
Home Improvement
Hurricane Shutters

Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Download these IBM resources today!
e-Kit: IBM Rational Systems Development Solution
With systems teams under so much pressure to develop products faster, reduce production costs, and react to changing business needs quickly, communication and collaboration seem to get lost. Now, theres a way to improve product quality and communication.

Webcast: Asset Reuse Strategies for Success--Innovate Don't Duplicate!
Searching for, identifying, updating, using and deploying software assets can be a difficult challenge.

eKit: Rational Build Forge Express
Access valuable resources to help you increase staff productivity, compress development cycles and deliver better software, fast.

Download: IBM Data Studio v1.1
Effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life.

eKit: Rational Asset Manager
Learn how to do more with your reusable assets, learn how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse.
Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

The Perl You Need to Know Special: Introduction to mod_perl Part 2

May 15, 2000

Last month we took a magical journey to the land of mod_perl, an idyllic paradise where the penalties of executing interpreted Perl code are greatly minimized. In that article, we focused on the exciting relationship between the Apache web server and the mod_perl module, and how this relationship optimizes execution of Perl by reducing forking and caching pre-compiled code within Apache child processes. This month, we shift our attention more towards actual code, and some ways in which your Perl code may need to be adapted to function properly within the environment created by mod_perl.

A Warm Familiar Place

When your Perl scripts are executed within a mod_perl environment, it is as if they are contained within a soothing and comfortable bubble. This bubble is like a microcosm of the "real world", in this case the real world being the operating system environment where Perl scripts are normally executed. Think of the mod_perl bubble like one of those miniature villages captured inside a glass ball which you can shake to cause a snowstorm or an earthquake. Life in this bubble is familiar and most things happen as they should -- but this bubble is not really the outside world, and there are some differences.

Like the terms "Xerox" and "Kleenex", the term "CGI" has come to be overextended to all server-side scripts that relate to the web server and browser. Technically, though, mod_perl scripts are not CGI scripts. However, because the CGI technology has come to define how we relate to parameters between the web server and our scripts, including such famous examples as Perl's CGI.pm module, we generally continue to use the CGI model and vocabulary in talking about mod_perl. And we continue to use CGI.pm, for instance, to manipulate form and state parameters sent from the web browser. All of this assumes you are using CGI.pm version of at least 2.36 and Perl 5.004+. It is still worth understanding, though, that mod_perl is in effect emulating the CGI environment for our convenience.

In a "real" operating system environment, Perl scripts are by default executed within the package named "main", assuming you have not declared otherwise. We haven't yet discussed packages in the Perl You Need to Know series, but you can think of a package as a namespace, or a context. So, you can have a subroutine or variable named PEPSI in package "blue" which will be independent of a subroutine or variable named PEPSI in package "red". This matters in mod_perl because Perl scripts do not run within the package "main" -- rather, they run within a uniquely named package based upon the URI of the web server resource. If you are familiar with packages, this information alone will be important. If you're thinking "so?", we'll see two important reasons this package stuff matters and the solutions over the next few pages.

Scripts are advised against using exit() calls, which are not supported by mod_perl, which prefers the Apache::exit() call. That said, there is a safety net in place and existing exit() calls will be intercepted and passed to the Apache exit routine.

Because the mod_perl bubble is such a familiar environment, many Perl scripts do not require modification to run under mod_perl. However, there are some significant cases of handling variables and subroutines where you may need to modify your Perl scripts to behave properly within the familiar yet sometimes strange bubble world of mod_perl.

Contents:

My() Troubles
Repackage Your Way to Success
Compilation Amnesia
Conclusion

Take Home Message: Optimizations
The Perl You Need to Know
My() Troubles


Up to => Home / Authoring / Languages / Perl / PerlfortheWeb




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers