Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

BooK (2612)

BooK
  {book} {at} {cpan.org}
http://paris.mongueurs.net/
Yahoo! ID: philippe_bruhat (Add User, Send Message)

Obfuscation [plover.com]. Pink [axis-of-aevil.net]. HTTP::Proxy [cpan.org]. YEF [yapceurope.org]. Fishnet [perl.org]. Kapow [cpan.org]. Cog's [perl.org] bitch [cpan.org]. Invitation [perl.org]. White [perl.org] Camel [perl.org]. Nuff' said.

Journal of BooK (2612)

Friday July 23, 2004
07:41 PM

Pod::POM and Perl::Tidy

[ #20028 ]

Thanks to Pod::POM and Perl::Tidy, all the Perl articles written by Les Mongueurs de Perl and published by GNU/Linux Magazine France now contain colored code examples.

The trickiest part was to prevent Perl::Tidy from choking on a verbatim, indented piece of code containing a here-document:

=begin tidy

    print << 'EOT';
    foo bar
    baz
    EOT
    $A++;

=end tidy

The text string passed to Perl::Tidy has to be munged so that line 4 is 'EOT' and not '<SP><SP><SP><SP>EOT'.

This was achieved by writing =begin tidy EOT and having the view remove all blanks at the begining of the lines matching the heredoc boundary, stacking them in an array (in case several heredocs in the code snippet used the same string) and putting them back after. A rather clumsy solution.

Luckily, while writing this entry I thought to myself: "Mmm, maybe another option would have been too simply unindent the whole code based on the first line and reindent it after Perl::Tidy's finished working on it." It really sounds much better and general this way.

Anyway, just have a look all these colorful Perl articles!

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.