How to format Perl/PHP code examples?

Hi everyone!

I don’t see anything relevant in a quick check of the forum and user manual, so I’ll ask here before I get too far in to typing.

I’m doing a long programmer tutorial. I’m not sure, yet, if I’ll publish the result on my WordPress blog, try it as my first Amazon Kindle ebook, or propose it as a short-book through Pragmatic Programmers. Thus I want to keep my formatting options wide open!

Does anyone have suggestions for how to handle the showing of sample code as illustrations? On a related note, if this were a blog-based tutorial, I’d be using H2 and H3 header tags to show section structure. If I recall correctly (it’s been a while), I can accomplish this in Scrivener with documents inside folders and compile settings for document titles.

Is this my best set-up as I set out to type stuff up? Make each code sample (even if a single line) a separate document, override the compile setting, and set to monospace font. At the same time, chop up the main text, perhaps down to single paragraph per document. But then that gives me trouble with the section/subsection titles; some documents have titles and some don’t.

Anyone have suggestions, or can point me to relevant instructions? Thanks!

Ed Barnard
Cannon Falls MN