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

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

More than 5 years have passed since last update.

@kayama0fa

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

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
35
Help us understand the problem. What are the problem?