views:

113

answers:

2

I really like my Perl code formatted - lines indented, etc. The problem is I hate doing it myself, and I really enjoy auto-formatters that do this automatically for you.

I work with Eclipse and the EPIC plugin does just that. The problem is that it does not handle comments very well. If comments are too long, it does not break them into multiple lines but simply shifts them to the beginning of the line, so the indention is not right at all.

Also, it keeps code lines about 80 characters long, which sometimes makes things ugly. From my school days I remember that too long line are bad, but now I wonder if perhaps it's better to just leave long lines as-is.

What do you say? any suggestions on how to format my Perl code under Eclipse (or in general)?

UPDATE

Eclipse's EPIC plugin also uses perl tidy. Any idea on how to make perl tidy break long code lines, but if it can't (e.g. long string) still indent them as normal and allow them to be longer (instead of indenting them all the way to the left as is the default?

+5  A: 

For a non IDE solution then have a look at Perl::Tidy.

This module is good at beautifying your Perl code into whatever style you have a preference with. However not sure that it has a long line/comment fixer though? (Disclaimer: I don't use Perl::Tidy because I'm happy with the way TextMate & Vi(m) handle my Perl code).

For an alternative IDE solution then have a look at Padre, the Perl Application Development and Refactoring Environment.

Padre is self hosting (ie. written in Perl5), cross platform (uses wxWidgets for GUI) and works with Perl5 & Perl6 (rakudo).

Here are some videos:

/I3az/

draegtun
+2  A: 

It looks like Eclipse/EPIC actually uses Perl::Tidy as its source formatter. Perl::Tidy is extremely flexible, so you probably just need to check the docs and set the options the way you want them.

The EPIC guide to setting those options: http://www.epic-ide.org/guide/ch02s04.php

RickF
Acvtually, it doesn't support my own formatting style: one feature is missing. But I use it anyway.
reinierpost