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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.