I'm a big one for understanding and making elegant use of layers of software, from the BIOS to the OS to the layers of applications, but I bit myself with a very simple gotcha that I'd like to share.

In my web work, I use Apache, mod_perl, and HTML::Embperl extensively. I'm a very code-oriented wonk, so Embperl suits my development style a lot more than some of the other templating systems available for Perl. One of the neat features of Embperl is it's ability to dynamically create a table for you from an array such as the result of an SQL query. Neat stuff that blows PHP completely out of my toolbox!

Unfortunately, the key element of this capability is an Embperl variable called $row. I also use Spreadsheet::WriteExcel to create spreadsheet files from the SQL data, and it's served me well. My code to date has always spawned a regular Perl program to do the file-writing, and it works. Over the last few days, I've been working on cleaning up my routines to make them more general and simpler, and I went 'round and 'round trying to figure out why my web daemon would hold my CPU hostage whenever I tried to write to the file. I mean, I could create the file, create a worksheet, and even set the name of it, but as soon as I tried to write anything, even a blank space, it would go for a Sunday drive and not come back!

I'm sure you all know the punch line: I'd used $row and $col as my spreadsheet-position variables and they clobbered Embperl.

Moral of the story: Always spend some cycles thinking about the layers of software that support your program when a bug seems intractable! :D

In reply to Layers of Software by samizdat

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.