I need a way to apply syntax highlighting to Perl code. (Mostly short snippets.) I do not require support for any other languages, although some rudimentary checking to differentiate Perl from non-Perl plain text would be a bonus. I realize nothing can parse Perl but perl, and this will not be an exact science, but it doesn't need to be; I just need it to 1) parse the snippets pretty well, most of the time (or fail somewhat gracefully if things get out of hand), and 2) not modify the code itself.
After some false starts with others, I spent a few hours with Perl::Tidy's formatter/write_line API with limited success. It seems to entirely discard lines of tokens if it gets even slightly confused, so my only recourse is to abandon the highlighting and render the source as plain text when that happens. I had less success with other mods.
I do have a slight preference for a server-side (Perl) implementation so I can pre-compile and cache all the XHTML to reduce page render times, thus the reason I'm asking here on perlmonks instead of a JS forum.