<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeremy Smyth's Blog &#187; Perltidy</title>
	<atom:link href="http://jeremysmyth.com/tag/perltidy/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeremysmyth.com</link>
	<description></description>
	<lastBuildDate>Tue, 10 Aug 2010 12:07:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Perl source-code formatting with Perltidy</title>
		<link>http://jeremysmyth.com/2008/11/06/perl-source-code-formatting-with-perltidy/</link>
		<comments>http://jeremysmyth.com/2008/11/06/perl-source-code-formatting-with-perltidy/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 16:12:07 +0000</pubDate>
		<dc:creator>Jeremy Smyth</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Formatting]]></category>
		<category><![CDATA[Perltidy]]></category>
		<category><![CDATA[Source-Code]]></category>

		<guid isPermaLink="false">http://jeremysmyth.com/?p=26</guid>
		<description><![CDATA[I was working on an open-source Perl application recently, paying particular attention to one of the modules within. Unfortunately, the formatting left a little to be desired, with a highly idiosyncratic and inconsistent level of indentation and use of bracketing.
Not one to be put off by this, I quickly installed perltidy, and ran it against [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on an open-source Perl application recently, paying particular attention to one of the modules within. Unfortunately, the formatting left a little to be desired, with a highly idiosyncratic and inconsistent level of indentation and use of bracketing.</p>
<p>Not one to be put off by this, I quickly installed <em>perltidy</em>, and ran it against the file.</p>
<p><tt>perltidy Package.pm</tt></p>
<p>After a few seconds, this created a file in the same directory called Perltidy.pm.tdy, with various changes made to the formatting.</p>
<p>The manpage showed it had a huge number of options, allowing one to choose from various different styles. For the most part, I was happy with the defaults. Although when coding C or LPC I prefer 3-space indents rather than two, Perl&#8217;s frequent use of block early-returns and flow modifiers like <tt>last</tt> and <tt>next</tt> means it makes sense to outdent them slightly. It&#8217;s easier to read such outdents when using 4-space indents.</p>
<p>My chosen options, in the end, looked like this:<br />
 -b        &#8211; inplace tidying, saves the original file to .bak, rather than creating a newly-styled file with .tdy extension.<br />
 -ce       &#8211; cuddle elses &#8211; the default places <tt>else</tt> on a new line after the previous closing brace, which allows closing-side comments, but disrupts the flow of the if statement.<br />
 -syn      &#8211; do a syntax check with Perl while tidying<br />
 -okw      &#8211; outdent keywords like <tt>next</tt> and <tt>last</tt><br />
 -csc      &#8211; enable closing-side comments &#8211; comments after the closing brace of a long sub or conditional statement.<br />
 -csci=12  &#8211; minimum number of lines in a block to add closing-side comment &#8211; the default is 6.</p>
<p><tt>perltidy -b -ce -syn -okw -csc -csci=12 Package.pm</tt></p>
<p>The problem now is how to check my changes back in without seriously upsetting the package maintainer; almost every line in the package has been changed, so the patch will be practically impossible for him to verify. Oh, well.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeremysmyth.com/2008/11/06/perl-source-code-formatting-with-perltidy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
