Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationEventAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.


perltidy - Perlソースコード整形ツール


CPAN Perltidy

How to install.

$ cpanm Perl::Tidy
which perltidyでInstall成功を確認


$HOME/.perltidyrcに以下のように書く(Perl best practicesより)

-l=78   # Max line width is 78 cols
-i=4    # Indent level is 4 cols
-ci=4   # Continuation indent is 4 cols
#-st     # Output to STDOUT
-se     # Errors to STDERR
-vt=2   # Maximal vertical tightness
-cti=0  # No extra indentation for closing brackets
-pt=1   # Medium parenthesis tightness
-bt=1   # Medium brace tightness
-sbt=1  # Medium square brace tightness
-bbt=1  # Medium block brace tightness
-nsfs   # No space before semicolons
-nolq   # Don't outdent long quoted strings
-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
        # Break before all operators

How to use.

$ perltidy target.pl

How to use. (emacs)


(defun perltidy-region ()               ;選択regionをperltidy
   "Run perltidy on the current region."
     (shell-command-on-region (point) (mark) "perltidy -q" nil t)))
(defun perltidy-defun ()                ;開いているソースをperltidy
  "Run perltidy on the current defun."
  (save-excursion (mark-defun)

* リージョン選択後、M-x perltidy-region → 選択範囲を整形
* Perlのソース上で、M-x perltidy-defun → ソース全体を整形(**以降は除外される)

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Help us understand the problem. What are the problem?