Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

About

Perlのソースコードを統一したルールで整形してくれる。
チームでコーディングするとき、特に有用。
CPAN Perltidy

How to install.

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

Setting

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

.perltidyrc
-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
target.plが整形される。

How to use. (emacs)

$HOME/.emacsに以下を追加。

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

使用方法
* リージョン選択後、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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした