Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: embperl

by edebill (Scribe)
on Jan 06, 2002 at 10:51 UTC ( [id://136656]=note: print w/replies, xml ) Need Help??


in reply to embperl tips?

use strict doesn't work too well, since [ ] blocks define code blocks - and the lifetime of my variables. This means you end up having lots of variables which are effectively global to the page. This means shorter pages will have less mysterious interaction between variables in widely separated places.

Beware the [$ if $] blocks. If you have a single file that actually paints more than one "page" it can get really hard to work with. Break those two pages out into their own files, then have a controlling file Execute() them. This has the added benefit that the page being Execute()ed effectively gets it's own namespace - you don't have to worry about it picking up stray variables from the other pages.

Another embperl page executing in the same apache process (perhaps for a previous request) will leave perl modules in the cache. That's really good for speed, but it means that you can forget to use those modules and the page will execute most of the time - the functions you are using will be loaded and the interpreter finds them just fine. This is a recurring source of intermittent errors. You have to be really careful to get all the the appropriate use statements on each page.

In the same vein, assuming you're using mod_perl, the interpreter won't notice if you modify a .pm. So even though it's changed on disk your page will keep using the old one until a new apache process starts up. MaxRequestsPerChild=1 in the httpd.conf is a workaround for development (I also know several people who have * * * * * /usr/local/apache/bin/apachectl restart crontab entries)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://136656]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 20:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found