Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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)


In reply to Re: embperl by edebill
in thread embperl tips? by tstock

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-14 23:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found