3 - Fixed RT #88020. --converge was not working with wide characters.
5 - Fixed RT #78156. package NAMESPACE VERSION syntax not accepted.
7 - First attempt to fix RT #88588. INDEX END tag change in pod2html breaks
8 perltidy -html. I put in a patch which should work but I don't yet have
12 - Fixed RT #87107, spelling
15 - Fixed RT #87502, incorrect of parsing of smartmatch before hash brace
17 - Added feature request RT #87330, trim whitespace after POD.
18 The flag -trp (--trim-pod) will trim trailing whitespace from lines of POD
21 - Fixed RT #86929, #86930, missing lhs of assignment.
23 - Fixed RT #84922, moved pod from Tidy.pm into Tidy.pod
26 - The flag -cab=n or --comma-arrow-breakpoints=n has been generalized
27 to give better control over breaking open short containers. The
28 possible values are now:
30 n=0 break at all commas after =>
31 n=1 stable: break at all commas after => if container is open,
32 EXCEPT FOR one-line containers
33 n=2 break at all commas after =>, BUT try to form the maximum
34 maximum one-line container lengths
35 n=3 do not treat commas after => specially at all
36 n=4 break everything: like n=0 but also break a short container with
37 a => not followed by a comma
38 n=5 stable: like n=1 but ALSO break at open one-line containers (default)
40 New values n=4 and n=5 have been added to allow short blocks to be
41 broken open. The new default is n=5, stable. It should more closely
42 follow the breaks in the input file, and previously formatted code
43 should remain unchanged. If this causes problems use -cab=1 to recover
44 the former behavior. Thanks to Tony Maszeroski for the suggestion.
46 To illustrate the need for the new options, if perltidy is given
47 the following code, then the old default (-cab=1) was to close up
48 the 'index' container even if it was open in the source. The new
49 default (-cab=5) will keep it open if it was open in the source.
64 - New debug flag --memoize (-mem). This version contains a
65 patch supplied by Jonathan Swartz which can significantly speed up
66 repeated calls to Perl::Tidy::perltidy in a single process by caching
67 the result of parsing the formatting parameters. A factor of up to 10
68 speedup was achieved for masontidy (https://metacpan.org/module/masontidy).
69 The memoization patch is on by default but can be deactivated for
70 testing with -nmem (or --no-memoize).
72 - New flag -tso (--tight-secret-operators) causes certain perl operator
73 sequences (secret operators) to be formatted "tightly" (without spaces).
74 The most common of these are 0 + and + 0 which become 0+ and +0. The
75 operators currently modified by this flag are:
76 =( )= 0+ +0 ()x!! ~~<> ,=>
77 Suggested by by Philippe Bruhat. See https://metacpan.org/module/perlsecret
78 This flag is off by default.
80 - New flag -vmll (--variable-maximum-line-length) makes the maximum
81 line length increase with the nesting depth of a line of code.
82 Basically, it causes the length of leading whitespace to be ignored when
83 setting line breaks, so the formatting of a block of code is independent
84 of its nesting depth. Try this option if you have deeply nested
85 code or data structures, perhaps in conjunction with the -wc flag
86 described next. The default is not todo this.
88 - New flag -wc=n (--whitespace-cycle=n) also addresses problems with
89 very deeply nested code and data structures. When this parameter is
90 used and the nesting depth exceeds the value n, the leading whitespace
91 will be reduced and start at 1 again. The result is that deeply
92 nested blocks of code will shift back to the left. This occurs cyclically
93 to any nesting depth. This flag may be used either with or without -vmll.
94 The default is not to use this (-wc=0).
96 - Fixed RT #78764, error parsing smartmatch operator followed by anonymous
97 hash or array and then a ternary operator; two examples:
99 qr/3/ ~~ ['1234'] ? 1 : 0;
100 map { $_ ~~ [ '0', '1' ] ? 'x' : 'o' } @a;
102 - Fixed problem with specifying spaces around arrows using -wls='->'
103 and -wrs='->'. Thanks to Alain Valleton for documenting this problem.
105 - Implemented RT #53183, wishlist, lines of code with the same indentation
106 level which are contained with multiple stacked opening and closing tokens
107 (requested with flags -sot -sct) now have reduced indentation.
118 # OLD: perltidy -sot -sct
125 # NEW: perltidy -sot -sct
132 - New flag -act=n (--all-containers-tightness=n) is an abbreviation for
133 -pt=n -sbt=n -bt=n -bbt=n, where n=0,1, or 2. It simplifies input when all
134 containers have the same tightness. Using the same example:
136 # NEW: perltidy -sot -sct -act=2
143 - New flag -sac (--stack-all-containers) is an abbreviation for -sot -sct
144 This is part of wishlist item RT #53183. Using the same example again:
146 # NEW: perltidy -sac -act=2
153 - new flag -scbb (--stack-closing-block-brace) causes isolated closing
154 block braces to stack as in the following example. (Wishlist item RT#73788)
161 push( @lines, "$w1 $w2 $w3 $w4\n" );
172 push( @lines, "$w1 $w2 $w3 $w4\n" );
175 There is, at present, no flag to place these closing braces at the end
176 of the previous line. It seems difficult to develop good rules for
177 doing this for a wide variety of code and data structures.
179 - Parameters defining block types may use a wildcard '*' to indicate
180 all block types. Previously it was not possible to include bare blocks.
182 - A flag -sobb (--stack-opening-block-brace) has been introduced as an
183 alias for -bbvt=2 -bbvtl='*'. So for example the following test code:
185 {{{{{{{ $testing }}}}}}}
187 cannot be formatted as above but can at least be kept vertically compact
188 using perltidy -sobb -scbb
190 { { { { { { { $testing
193 Or even, perltidy -sobb -scbb -i=1 -bbt=2
198 - Error message improved for conflicts due to -pbp; thanks to Djun Kim.
200 - Fixed RT #80645, error parsing special array name '@$' when used as
203 - Eliminated the -chk debug flag which was included in version 20010406 to
204 do a one-time check for a bug with multi-line quotes. It has not been
207 - Numerous other minor formatting improvements.
210 - Added flag -iscl (--ignore-side-comment-lengths) which causes perltidy
211 to ignore the length of side comments when setting line breaks,
212 RT #71848. The default is to include the length of side comments when
213 breaking lines to stay within the length prescribed by the -l=n
214 maximum line length parameter. For example,
216 Default behavior on a single line with long side comment:
217 $vmsfile =~ s/;[\d\-]*$//
218 ; # Clip off version number; we can use a newer version as well
220 perltidy -iscl leaves the line intact:
222 $vmsfile =~ s/;[\d\-]*$//; # Clip off version number; we can use a newer version as well
224 - Fixed RT #78182, side effects with STDERR. Error handling has been
225 revised and the documentation has been updated. STDERR can now be
226 redirected to a string reference, and perltidy now returns an
227 error flag instead of calling die when input errors are detected.
228 If the error flag is set then no tidied output was produced.
229 See man Perl::Tidy for an example.
231 - Fixed RT #78156, erroneous warning message for package VERSION syntax.
233 - Added abbreviations -conv (--converge) to simplify iteration control.
234 -conv is equivalent to -it=4 and will insure that the tidied code is
235 converged to its final state with the minimum number of iterations.
237 - Minor formatting modifications have been made to insure convergence.
239 - Simplified and hopefully improved the method for guessing the starting
240 indentation level of entabbed code. Added flag -dt=n (--default_tabsize=n)
241 which might be helpful if the guessing method does not work well for
244 - Added support for stacked labels, upper case X/B in hex and binary, and
247 - Eliminated warning messages for using keyword names as constants.
250 - Corrected problem introduced by using a chomp on scalar references, RT #77978
252 - Added support for Perl 5.14 package block syntax, RT #78114.
254 - A convergence test is made if three or more iterations are requested with
255 the -it=n parameter to avoid wasting computer time. Several hundred Mb of
256 code gleaned from the internet were searched with the results that:
257 - It is unusual for two iterations to be required unless a major
258 style change is being made.
259 - Only one case has been found where three iterations were required.
260 - No cases requiring four iterations have been found with this version.
261 For the previous version several cases where found the results could
262 oscillate between two semi-stable states. This version corrects this.
264 So if it is important that the code be converged it is okay to set -it=4
265 with this version and it will probably stop after the second iteration.
267 - Improved ability to identify and retain good line break points in the
268 input stream, such as at commas and equals. You can always tell
269 perltidy to ignore old breakpoints with -iob.
271 - Fixed glitch in which a terminal closing hash brace followed by semicolon
272 was not outdented back to the leading line depth like other closing
273 tokens. Thanks to Keith Neargarder for noting this.
276 my ( $pre, $post ) = @{
278 "pp_anonlist" => [ "[", "]" ],
279 "pp_anonhash" => [ "{", "}" ]
284 my ( $pre, $post ) = @{
286 "pp_anonlist" => [ "[", "]" ],
287 "pp_anonhash" => [ "{", "}" ]
291 - Removed extra indentation given to trailing 'if' and 'unless' clauses
292 without parentheses because this occasionally produced undesirable
293 results. This only applies where parens are not used after the if or
298 unless my ( $who, $actions ) =
299 $clause =~ /^($who_re)((?:$action_re)+)$/o;
303 unless my ( $who, $actions ) =
304 $clause =~ /^($who_re)((?:$action_re)+)$/o;
307 - Updated perltidy to handle all quote modifiers defined for perl 5 version 16.
309 - Side comment text in perltidyrc configuration files must now begin with
310 at least one space before the #. Thus:
313 -l=78 # Max line width is 78 cols
315 -l=78# Max line width is 78 cols
317 This is probably true of almost all existing perltidyrc files,
318 but if you get an error message about bad parameters
319 involving a '#' the first time you run this version, please check the side
320 comments in your perltidyrc file, and add a space before the # if necessary.
321 You can quickly see the contents your perltidyrc file, if any, with the
326 The reason for this change is that some parameters naturally involve
327 the # symbol, and this can get interpreted as a side comment unless the
328 parameter is quoted. For example, to define -sphb=# it used to be necessary
331 to keep the # from becoming part of a comment. This was causing
332 trouble for new users. Now it can also be written without quotes:
335 - Fixed bug in processing some .perltidyrc files containing parameters with
336 an opening brace character, '{'. For example the following was
337 incorrectly processed:
338 --static-block-comment-prefix="^#{2,}[^\s#]"
341 - Added flag -boa (--break-at-old-attribute-breakpoints) which retains
342 any existing line breaks at attribute separation ':'. This is now the
343 default, use -nboa to deactivate. Thanks to Daphne Phister for the patch.
344 For example, given the following code, the line breaks at the ':'s will be
350 : Get('Name' => 'foo') : Set('Name');
352 whereas the previous version would have output a single line. If
353 the attributes are on a single line then they will remain on a single line.
355 - Added new flags --blank-lines-before-subs=n (-blbs=n) and
356 --blank-lines-before-packages=n (-blbp=n) to put n blank lines before
357 subs and packages. The old flag -bbs is now equivalent to -blbs=1 -blbp=1.
358 and -nbbs is equivalent to -blbs=0 -blbp=0. Requested by M. Schwern and
361 - Added feature -nsak='*' meaning no space between any keyword and opening
362 paren. This avoids listing entering a long list of keywords. Requested
365 - Added option to delete a backup of original file with in-place-modify (-b)
366 if there were no errors. This can be requested with the flag -bext='/'.
367 See documentation for details. Requested by M. Schwern and others.
369 - Fixed bug where the module postfilter parameter was not applied when -b
370 flag was used. This was discovered during testing.
372 - Fixed in-place-modify (-b) to work with symbolic links to source files.
373 Thanks to Ted Johnson.
375 - Fixed bug where the Perl::Tidy module did not allow -b to be used
378 - No extra blank line is added before a comment which follows
379 a short line ending in an opening token, for example like this:
383 # unless we follow a blank or comment line
384 $last_line_leading_type !~ /^[#b]$/
389 # unless we follow a blank or comment line
390 $last_line_leading_type !~ /^[#b]$/
393 The blank is not needed for readability in these cases because there
394 already is already space above the comment. If a blank already
395 exists there it will not be removed, so this change should not
396 change code which has previously been formatted with perltidy.
397 Thanks to R.W.Stauner.
399 - Likewise, no extra blank line is added above a comment consisting of a
400 single #, since nothing is gained in readability.
402 - Fixed error in which a blank line was removed after a #>>> directive.
403 Thanks to Ricky Morse.
405 - Unnecessary semicolons after given/when/default blocks are now removed.
407 - Fixed bug where an unwanted blank line could be added before
408 pod text in __DATA__ or __END__ section. Thanks to jidani.
410 - Changed exit flags from 1 to 0 to indicate success for -help, -version,
411 and all -dump commands. Also added -? as another way to dump the help.
412 Requested by Keith Neargarder.
414 - Fixed bug where .ERR and .LOG files were not written except for -it=2 or more
416 - Fixed bug where trailing blank lines at the end of a file were dropped when
419 - Fixed bug where a line occasionally ended with an extra space. This reduces
420 rhe number of instances where a second iteration gives a result different
423 - Updated documentation to note that the Tidy.pm module <stderr> parameter may
424 not be a reference to SCALAR or ARRAY; it must be a file.
426 - Syntax check with perl now work when the Tidy.pm module is processing
427 references to arrays and strings. Thanks to Charles Alderman.
429 - Zero-length files are no longer processed due to concerns for data loss
430 due to side effects in some scenarios.
432 - block labels, if any, are now included in closing side comment text
433 when the -csc flag is used. Suggested by Aaron. For example,
434 the label L102 in the following block is now included in the -csc text:
436 L102: for my $i ( 1 .. 10 ) {
438 } ## end L102: for my $i ( 1 .. 10 )
441 - added new flag -it=n or --iterations=n
442 This flag causes perltidy to do n complete iterations.
443 For most purposes the default of n=1 should be satisfactory. However n=2
444 can be useful when a major style change is being made, or when code is being
445 beautified on check-in to a source code control system. The run time will be
446 approximately proportional to n, and it should seldom be necessary to use a
447 value greater than n=2. Thanks to Jonathan Swartz
449 - A configuration file pathname begins with three dots, e.g.
450 ".../.perltidyrc", indicates that the file should be searched for starting
451 in the current directory and working upwards. This makes it easier to have
452 multiple projects each with their own .perltidyrc in their root directories.
453 Thanks to Jonathan Swartz for this patch.
455 - Added flag --notidy which disables all formatting and causes the input to be
456 copied unchanged. This can be useful in conjunction with hierarchical
457 F<.perltidyrc> files to prevent unwanted tidying.
458 Thanks to Jonathan Swartz for this patch.
460 - Added prefilters and postfilters in the call to the Tidy.pm module.
461 Prefilters and postfilters. The prefilter is a code reference that
462 will be applied to the source before tidying, and the postfilter
463 is a code reference to the result before outputting.
465 Thanks to Jonathan Swartz for this patch. He writes:
466 This is useful for all manner of customizations. For example, I use
467 it to convert the 'method' keyword to 'sub' so that perltidy will work for
468 Method::Signature::Simple code:
470 Perl::Tidy::perltidy(
471 prefilter => sub { $_ = $_[0]; s/^method (.*)/sub $1 \#__METHOD/gm; return $_ },
472 postfilter => sub { $_ = $_[0]; s/^sub (.*?)\s* \#__METHOD/method $1/gm; return $_ }
475 - The starting indentation level of sections of code entabbed with -et=n
476 is correctly guessed if it was also produced with the same -et=n flag. This
477 keeps the indentation stable on repeated formatting passes within an editor.
478 Thanks to Sam Kington and Glenn.
480 - Functions with prototype '&' had a space between the function and opening
481 peren. This space now only occurs if the flag --space-function-paren (-sfp)
482 is set. Thanks to Zrajm Akfohg.
484 - Patch to never put spaces around a bare word in braces beginning with ^ as in:
485 my $before = ${^PREMATCH};
486 even if requested with the -bt=0 flag because any spaces cause a syntax error in perl.
487 Thanks to Fabrice Dulanoy.
490 - Allow configuration file to be 'perltidy.ini' for Windows systems.
491 i.e. C:\Documents and Settings\User\perltidy.ini
492 and added documentation for setting configuation file under Windows in man
493 page. Thanks to Stuart Clark.
495 - Corrected problem of unwanted semicolons in hash ref within given/when code.
496 Thanks to Nelo Onyiah.
498 - added new flag -cscb or --closing-side-comments-balanced
499 When using closing-side-comments, and the closing-side-comment-maximum-text
500 limit is exceeded, then the comment text must be truncated. Previous
501 versions of perltidy terminate with three dots, and this can still be
502 achieved with -ncscb:
506 } ## end foreach my $foo (sort { $b cmp $a ...
508 However this causes a problem with older editors which cannot recognize
509 comments or are not configured to doso because they cannot "bounce" around in
510 the text correctly. The B<-cscb> flag tries to help them by
511 appending appropriate terminal balancing structure:
515 } ## end foreach my $foo (sort { $b cmp $a ... })
517 Since there is much to be gained and little to be lost by doing this,
518 the default is B<-cscb>. Use B<-ncscb> if you do not want this.
520 Thanks to Daniel Becker for suggesting this option.
522 - After an isolated closing eval block the continuation indentation will be
523 removed so that the braces line up more like other blocks. Thanks to Yves Orton.
542 -A new flag -asbl (or --opening-anonymous-sub-brace-on-new-line) has
543 been added to put the opening brace of anonymous sub's on a new line,
544 as in the following snippet:
552 This was not possible before because the -sbl flag only applies to named
553 subs. Thanks to Benjamin Krupp.
555 -Fix tokenization bug with the following snippet
556 print 'hi' if { x => 1, }->{x};
557 which resulted in a semicolon being added after the comma. The workaround
558 was to use -nasc, but this is no longer necessary. Thanks to Brian Duggan.
560 -Fixed problem in which an incorrect error message could be triggered
561 by the (unusual) combination of parameters -lp -i=0 -l=2 -ci=0 for
562 example. Thanks to Richard Jelinek.
564 -A new flag --keep-old-blank-lines=n has been added to
565 give more control over the treatment of old blank lines in
566 a script. The manual has been revised to discuss the new
567 flag and clarify the treatment of old blank lines. Thanks
571 -Improved support for perl 5.10: New quote modifier 'p', new block type UNITCHECK,
572 new keyword break, improved formatting of given/when.
574 -Corrected tokenization bug of something like $var{-q}.
576 -Numerous minor formatting improvements.
578 -Corrected list of operators controlled by -baao -bbao to include
579 . : ? && || and or err xor
581 -Corrected very minor error in log file involving incorrect comment
582 regarding need for upper case of labels.
584 -Fixed problem where perltidy could run for a very long time
585 when given certain non-perl text files.
587 -Line breaks in un-parenthesized lists now try to follow
588 line breaks in the input file rather than trying to fill
589 lines. This usually works better, but if this causes
590 trouble you can use -iob to ignore any old line breaks.
591 Example for the following input snippet:
594 "conformability (Not the same dimension)\n",
595 "\t", $have, " is ", text_unit($hu), "\n",
596 "\t", $want, " is ", text_unit($wu), "\n",
600 print "conformability (Not the same dimension)\n", "\t", $have, " is ",
601 text_unit($hu), "\n", "\t", $want, " is ", text_unit($wu), "\n",;
604 print "conformability (Not the same dimension)\n",
605 "\t", $have, " is ", text_unit($hu), "\n",
606 "\t", $want, " is ", text_unit($wu), "\n",
610 -Added -fpsc option (--fixed-position-side-comment). Thanks to Ueli Hugenschmidt.
611 For example -fpsc=40 tells perltidy to put side comments in column 40
614 -Added -bbao and -baao options (--break-before-all-operators and
615 --break-after-all-operators) to simplify command lines and configuration
616 files. These define an initial preference for breaking at operators which can
617 be modified with -wba and -wbb flags. For example to break before all operators
618 except an = one could use --bbao -wba='=' rather than listing every
619 single perl operator (except =) on a -wbb flag.
621 -Added -kis option (--keep-interior-semicolons). Use the B<-kis> flag
622 to prevent breaking at a semicolon if there was no break there in the
623 input file. To illustrate, consider the following input lines:
625 dbmclose(%verb_delim); undef %verb_delim;
626 dbmclose(%expanded); undef %expanded;
627 dbmclose(%global); undef %global;
629 Normally these would be broken into six lines, but
632 dbmclose(%verb_delim); undef %verb_delim;
633 dbmclose(%expanded); undef %expanded;
634 dbmclose(%global); undef %global;
636 -Improved formatting of complex ternary statements, with indentation
637 of nested statements.
639 return defined( $cw->{Selected} )
641 ? @{ $cw->{Selected} }
646 return defined( $cw->{Selected} )
648 ? @{ $cw->{Selected} }
652 -Text following un-parenthesized if/unless/while/until statements get a
653 full level of indentation. Suggested by Jeff Armstorng and others.
655 return $ship->chargeWeapons("phaser-canon")
656 if $encounter->description eq 'klingon'
657 and $ship->firepower >= $encounter->firepower
658 and $location->status ne 'neutral';
660 return $ship->chargeWeapons("phaser-canon")
661 if $encounter->description eq 'klingon'
662 and $ship->firepower >= $encounter->firepower
663 and $location->status ne 'neutral';
666 -Fixed bug where #line directives were being indented. Thanks to
670 -Fixed problem where an extra blank line was added after an =cut when either
671 (a) the =cut started (not stopped) a POD section, or (b) -mbl > 1.
672 Thanks to J. Robert Ray and Bill Moseley.
675 -ole (--output-line-ending) and -ple (--preserve-line-endings) should
676 now work on all systems rather than just unix systems. Thanks to Dan
679 -Fixed problem of a warning issued for multiple subs for BEGIN subs
680 and other control subs. Thanks to Heiko Eissfeldt.
682 -Fixed problem where no space was introduced between a keyword or
683 bareword and a colon, such as:
685 ( ref($result) eq 'HASH' && !%$result ) ? undef: $result;
689 -Added a utility program 'break_long_quotes.pl' to the examples directory of
690 the distribution. It breaks long quoted strings into a chain of concatenated
691 sub strings no longer than a selected length. Suggested by Michael Renner as
692 a perltidy feature but was judged to be best done in a separate program.
694 -Updated docs to remove extra < and >= from list of tokens
695 after which breaks are made by default. Thanks to Bob Kleemann.
697 -Removed improper uses of $_ to avoid conflicts with external calls, giving
698 error message similar to:
699 Modification of a read-only value attempted at
700 /usr/share/perl5/Perl/Tidy.pm line 6907.
701 Thanks to Michael Renner.
703 -Fixed problem when errorfile was not a plain filename or filehandle
704 in a call to Tidy.pm. The call
705 perltidy(source => \$input, destination => \$output, errorfile => \$err);
706 gave the following error message:
707 Not a GLOB reference at /usr/share/perl5/Perl/Tidy.pm line 3827.
708 Thanks to Michael Renner and Phillipe Bruhat.
710 -Fixed problem where -sot would not stack an opening token followed by
711 a side comment. Thanks to Jens Schicke.
713 -improved breakpoints in complex math and other long statements. Example:
716 log($n) + 0.577215664901532 + ( 1 / ( 2 * $n ) ) -
717 ( 1 / ( 12 * ( $n**2 ) ) ) + ( 1 / ( 120 * ( $n**4 ) ) );
720 log($n) + 0.577215664901532 +
722 ( 1 / ( 12 * ( $n**2 ) ) ) +
723 ( 1 / ( 120 * ( $n**4 ) ) );
725 -more robust vertical alignment of complex terminal else blocks and ternary
729 -Eliminated bug where a here-doc invoked through an 'e' modifier on a pattern
730 replacement text was not recognized. The tokenizer now recursively scans
731 replacement text (but does not reformat it).
733 -improved vertical alignment of terminal else blocks and ternary statements.
734 Thanks to Chris for the suggestion.
737 if ( IsBitmap() ) { return GetBitmap(); }
738 elsif ( IsFiles() ) { return GetFiles(); }
739 else { return GetText(); }
742 if ( IsBitmap() ) { return GetBitmap(); }
743 elsif ( IsFiles() ) { return GetFiles(); }
744 else { return GetText(); }
749 : $opts{"s"} ? 'subject'
750 : $opts{"a"} ? 'author'
756 : $opts{"s"} ? 'subject'
757 : $opts{"a"} ? 'author'
760 -improved indentation of try/catch blocks and other externally defined
761 functions accepting a block argument. Thanks to jae.
763 -Added support for Perl 5.10 features say and smartmatch.
765 -Added flag -pbp (--perl-best-practices) as an abbreviation for parameters
766 suggested in Damian Conway's "Perl Best Practices". -pbp is the same as:
768 -l=78 -i=4 -ci=4 -st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nsfs -nolq
769 -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < =
770 **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
772 Please note that the -st here restricts input to standard input; use
773 -nst if necessary to override.
775 -Eliminated some needless breaks at equals signs in -lp indentation.
779 Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE,
780 TOP + $y * (BOTTOM - TOP) / SIZE);
782 $c = Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE,
783 TOP + $y * (BOTTOM - TOP) / SIZE);
785 A break at an equals is sometimes useful for preventing complex statements
786 from hitting the line length limit. The decision to do this was
787 over-eager in some cases and has been improved. Thanks to Royce Reece.
789 -qw quotes contained in braces, square brackets, and parens are being
790 treated more like those containers as far as stacking of tokens. Also
791 stack of closing tokens ending ');' will outdent to where the ');' would
792 have outdented if the closing stack is matched with a similar opening stack.
794 OLD: perltidy -soc -sct
795 __PACKAGE__->load_components(
801 NEW: perltidy -soc -sct
802 __PACKAGE__->load_components( qw(
806 Thanks to Aran Deltac
808 -Eliminated some undesirable or marginally desirable vertical alignments.
809 These include terminal colons, opening braces, and equals, and particularly
810 when just two lines would be aligned.
813 my $accurate_timestamps = $Stamps{lnk};
817 my $accurate_timestamps = $Stamps{lnk};
820 -Corrected a problem with -mangle in which a space would be removed
821 between a keyword and variable beginning with ::.
824 -Attribute argument lists are now correctly treated as quoted strings
825 and not formatted. This is the most important update in this version.
826 Thanks to Borris Zentner, Greg Ferguson, Steve Kirkup.
828 -Updated to recognize the defined or operator, //, to be released in Perl 10.
829 Thanks to Sebastien Aperghis-Tramoni.
831 -A useful utility perltidyrc_dump.pl is included in the examples section. It
832 will read any perltidyrc file and write it back out in a standard format
833 (though comments are lost).
835 -Added option to have perltidy read and return a hash with the contents of a
836 perltidyrc file. This may be used by Leif Eriksen's tidyview code. This
837 feature is used by the demonstration program 'perltidyrc_dump.pl' in the
840 -Improved error checking in perltidyrc files. Unknown bare words were not
843 -The --dump-options parameter now dumps parameters in the format required by a
846 -V-Strings with underscores are now recognized.
847 For example: $v = v1.2_3;
849 -cti=3 option added which gives one extra indentation level to closing
850 tokens always. This provides more predictable closing token placement
851 than cti=2. If you are using cti=2 you might want to try cti=3.
853 -To identify all left-adjusted comments as static block comments, use C<-sbcp='^#'>.
855 -New parameters -fs, -fsb, -fse added to allow sections of code between #<<<
856 and #>>> to be passed through verbatim. This is enabled by default and turned
857 off by -nfs. Flags -fsb and -fse allow other beginning and ending markers.
858 Thanks to Wolfgang Werner and Marion Berryman for suggesting this.
860 -added flag -skp to put a space between all Perl keywords and following paren.
861 The default is to only do this for certain keywords. Suggested by
864 -added flag -sfp to put a space between a function name and following paren.
865 The default is not to do this. Suggested by H.Merijn Brand.
867 -Added patch to avoid breaking GetOpt::Long::Configure set by calling program.
868 Thanks to Philippe Bruhat.
870 -An error was fixed in which certain parameters in a .perltidyrc file given
871 without the equals sign were not recognized. That is,
872 '--brace-tightness 0' gave an error but '--brace-tightness=0' worked
873 ok. Thanks to Zac Hansen.
875 -An error preventing the -nwrs flag from working was corrected. Thanks to
878 -Corrected some alignment problems with entab option.
880 -A bug with the combination of -lp and -extrude was fixed (though this
881 combination doesn't really make sense). The bug was that a line with
882 a single zero would be dropped. Thanks to Cameron Hayne.
884 -Updated Windows detection code to avoid an undefined variable.
885 Thanks to Joe Yates and Russ Jones.
887 -Improved formatting for short trailing statements following a closing paren.
888 Thanks to Joe Matarazzo.
890 -The handling of the -icb (indent closing block braces) flag has been changed
891 slightly to provide more consistent and predictable formatting of complex
892 structures. Instead of giving a closing block brace the indentation of the
893 previous line, it is now given one extra indentation level. The two methods
894 give the same result if the previous line was a complete statement, as in this
903 The change also fixes a problem with empty blocks such as:
913 -A problem with -icb was fixed in which a closing brace was misplaced when
914 it followed a quote which spanned multiple lines.
916 -Some improved breakpoints for -wba='&& || and or'
918 -Fixed problem with misaligned cuddled else in complex statements
919 when the -bar flag was also used. Thanks to Alex and Royce Reese.
921 -Corrected documentation to show that --outdent-long-comments is the default.
924 -New flag -otr (opening-token-right) is similar to -bar (braces-always-right)
925 but applies to non-structural opening tokens.
927 -new flags -sot (stack-opening-token), -sct (stack-closing-token).
931 -The default has been changed to not do syntax checking with perl.
932 Use -syn if you want it. Perltidy is very robust now, and the -syn
933 flag now causes more problems than it's worth because of BEGIN blocks
934 (which get executed with perl -c). For example, perltidy will never
935 return when trying to beautify this code if -syn is used:
937 BEGIN { 1 while { }; }
939 Although this is an obvious error, perltidy is often run on untested
940 code which is more likely to have this sort of problem. A more subtle
943 BEGIN { use FindBin; }
945 which may hang on some systems using -syn if a shared file system is
948 -Changed style -gnu to use -cti=1 instead of -cti=2 (see next item).
949 In most cases it looks better. To recover the previous format, use
952 -Added flags -cti=n for finer control of closing token indentation.
953 -cti = 0 no extra indentation (default; same as -nicp)
954 -cti = 1 enough indentation so that the closing token
955 aligns with its opening token.
956 -cti = 2 one extra indentation level if the line has the form
957 ); ]; or }; (same as -icp).
959 The new option -cti=1 works well with -lp:
963 # perltidy -lp -cti=1
965 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
966 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
969 # perltidy -lp -cti=2
971 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
972 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
974 This is backwards compatible with -icp. See revised manual for
975 details. Suggested by Mike Pennington.
977 -Added flag '--preserve-line-endings' or '-ple' to cause the output
978 line ending to be the same as in the input file, for unix, dos,
979 or mac line endings. Only works under unix. Suggested by
982 -Added flag '--output-line-ending=s' or '-ole=s' where s=dos or win,
983 unix, or mac. Only works under unix.
985 -Files with Mac line endings should now be handled properly under unix
986 and dos without being passed through a converter.
988 -You may now include 'and', 'or', and 'xor' in the list following
989 '--want-break-after' to get line breaks after those keywords rather than
990 before them. Suggested by Rainer Hochschild.
992 -Corrected problem with command line option for -vtc=n and -vt=n. The
993 equals sign was being eaten up by the Windows shell so perltidy didn't
997 -Corrected cause of warning message with recent versions of Perl:
998 "Possible precedence problem on bitwise & operator at ..."
1001 -fixed bug with -html with '=for pod2html' sections, in which code/pod
1002 output order was incorrect. Thanks to Tassilo von Parseval.
1004 -fixed bug when the -html flag is used, in which the following error
1005 message, plus others, appear:
1006 did not see <body> in pod2html output
1007 This was caused by a change in the format of html output by pod2html
1008 VERSION 1.04 (included with perl 5.8). Thanks to Tassilo von Parseval.
1010 -Fixed bug where an __END__ statement would be mistaken for a label
1011 if it is immediately followed by a line with a leading colon. Thanks
1014 -Implemented guessing logic for brace types when it is ambiguous. This
1015 has been on the TODO list a long time. Thanks to Boris Zentner for
1018 -Long options may now be negated either as '--nolong-option'
1019 or '--no-long-option'. Thanks to Philip Newton for the suggestion.
1021 -added flag --html-entities or -hent which controls the use of
1022 Html::Entities for html formatting. Use --nohtml-entities or -nhent to
1023 prevent the use of Html::Entities to encode special symbols. The
1024 default is -hent. Html::Entities when formatting perl text to escape
1025 special symbols. This may or may not be the right thing to do,
1026 depending on browser/language combinations. Thanks to Burak Gursoy for
1029 -Bareword strings with leading '-', like, '-foo' now count as 1 token
1030 for horizontal tightness. This way $a{'-foo'}, $a{foo}, and $a{-foo}
1031 are now all treated similarly. Thus, by default, OLD: $a{ -foo } will
1032 now be NEW: $a{-foo}. Suggested by Mark Olesen.
1034 -added 2 new flags to control spaces between keywords and opening parens:
1035 -sak=s or --space-after-keyword=s, and
1036 -nsak=s or --nospace-after-keyword=s, where 's' is a list of keywords.
1038 The new default list of keywords which get a space is:
1040 "my local our and or eq ne if else elsif until unless while for foreach
1041 return switch case given when"
1043 Use -sak=s and -nsak=s to add and remove keywords from this list,
1046 Explanation: Stephen Hildrey noted that perltidy was being inconsistent
1047 in placing spaces between keywords and opening parens, and sent a patch
1048 to give user control over this. The above list was selected as being
1049 a reasonable default keyword list. Previously, perltidy
1050 had a hardwired list which also included these keywords:
1052 push pop shift unshift join split die
1054 but did not have 'our'. Example: if you prefer to make perltidy behave
1055 exactly as before, you can include the following two lines in your
1058 -sak="push pop local shift unshift join split die"
1061 -Corrected html error in .toc file when -frm -html is used (extra ");
1062 browsers were tolerant of it.
1064 -Improved alignment of chains of binary and ?/: operators. Example:
1078 -improved breakpoint choices involving '->'
1080 -Corrected tokenization of things like ${#} or ${©}. For example,
1081 ${©} is valid, but ${© } is a syntax error.
1083 -Corrected minor tokenization errors with indirect object notation.
1084 For example, 'new A::()' works now.
1086 -Minor tokenization improvements; all perl code distributed with perl 5.8
1087 seems to be parsed correctly except for one instance (lextest.t)
1091 -Implemented scalar attributes. Thanks to Sean Tobin for noting this.
1093 -Fixed glitch introduced in previous release where -pre option
1094 was not outputting a leading html <pre> tag.
1096 -Numerous minor improvements in vertical alignment, including the following:
1098 -Improved alignment of opening braces in many cases. Needed for improved
1099 switch/case formatting, and also suggested by Mark Olesen for sort/map/grep
1100 formatting. For example:
1105 sort { $a->[1] <=> $b->[1] }
1106 map { [ $_, -M ] } @filenames;
1111 sort { $a->[1] <=> $b->[1] }
1112 map { [ $_, -M ] } @filenames;
1114 -Eliminated alignments across unrelated statements. Example:
1116 $borrowerinfo->configure( -state => 'disabled' );
1117 $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' );
1120 $borrowerinfo->configure( -state => 'disabled' );
1121 $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' );
1123 Thanks to Mark Olesen for suggesting this.
1125 -Improved alignement of '='s in certain cases.
1126 Thanks to Norbert Gruener for sending an example.
1128 -Outdent-long-comments (-olc) has been re-instated as a default, since
1129 it works much better now. Use -nolc if you want to prevent it.
1131 -Added check for 'perltidy file.pl -o file.pl', which causes file.pl
1132 to be lost. (The -b option should be used instead). Thanks to mreister
1133 for reporting this problem.
1136 -Switch/case or given/when syntax is now recognized. Its vertical alignment
1137 is not great yet, but it parses ok. The words 'switch', 'case', 'given',
1138 and 'when' are now treated as keywords. If this causes trouble with older
1139 code, we could introduce a switch to deactivate it. Thanks to Stan Brown
1140 and Jochen Schneider for recommending this.
1142 -Corrected error parsing sub attributes with call parameters.
1143 Thanks to Marc Kerr for catching this.
1145 -Sub prototypes no longer need to be on the same line as sub names.
1147 -a new flag -frm or --frames will cause html output to be in a
1148 frame, with table of contents in the left panel and formatted source
1149 in the right panel. Try 'perltidy -html -frm somemodule.pm' for example.
1151 -The new default for -html formatting is to pass the pod through Pod::Html.
1152 The result is syntax colored code within your pod documents. This can be
1153 deactivated with -npod. Thanks to those who have written to discuss this,
1154 particularly Mark Olesen and Hugh Myers.
1156 -the -olc (--outdent-long-comments) option works much better. It now outdents
1157 groups of consecutive comments together, and by just the amount needed to
1158 avoid having any one line exceeding the maximum line length.
1160 -block comments are now trimmed of trailing whitespace.
1162 -if a directory specified with -opath does not exist, it will be created.
1164 -a table of contents to packages and subs is output when -html is used.
1165 Use -ntoc to prevent this.
1167 -fixed an unusual bug in which a 'for' statement following a 'format'
1168 statement was not correctly tokenized. Thanks to Boris Zentner for
1171 -Tidy.pm is no longer dependent on modules IO::Scalar and IO::ScalarArray.
1172 There were some speed issues. Suggested by Joerg Walter.
1174 -The treatment of quoted wildcards (file globs) is now system-independent.
1177 perltidy 'b*x.p[lm]'
1179 would match box.pl, box.pm, brinx.pm under any operating system. Of
1180 course, anything unquoted will be subject to expansion by any shell.
1182 -default color for keywords under -html changed from
1183 SaddleBrown (#8B4513) to magenta4 (#8B008B).
1185 -fixed an arg parsing glitch in which something like:
1187 would trigger the help message and exit, rather than operate on the
1191 -New option '-b' or '--backup-and-modify-in-place' will cause perltidy to
1192 overwrite the original file with the tidied output file. The original
1193 file will be saved with a '.bak' extension (which can be changed with
1194 -bext=s). Thanks to Rudi Farkas for the suggestion.
1196 -An index to all subs is included at the top of -html output, unless
1197 only the <pre> section is written.
1199 -Anchor lines of the form <a name="mysub"></a> are now inserted at key points
1200 in html output, such as before sub definitions, for the convenience of
1201 postprocessing scripts. Suggested by Howard Owen.
1203 -The cuddled-else (-ce) flag now also makes cuddled continues, like
1206 while ( ( $pack, $file, $line ) = caller( $i++ ) ) {
1212 Suggested by Simon Perreault.
1214 -Fixed bug in which an extra blank line was added before an =head or
1215 similar pod line after an __END__ or __DATA__ line each time
1216 perltidy was run. Also, an extra blank was being added after
1217 a terminal =cut. Thanks to Mike Birdsall for reporting this.
1220 -Fixed bug in which space was inserted in a hyphenated hash key:
1221 my $val = $myhash{USER-NAME};
1223 my $val = $myhash{USER -NAME};
1224 Thanks to an anonymous bug reporter at sourceforge.
1226 -Fixed problem with the '-io' ('--indent-only') where all lines
1227 were double spaced. Thanks to Nick Andrew for reporting this bug.
1229 -Fixed tokenization error in which something like '-e1' was
1232 -Corrected a rare problem involving older perl versions, in which
1233 a line break before a bareword caused problems with 'use strict'.
1234 Thanks to Wolfgang Weisselberg for noting this.
1236 -More syntax error checking added.
1238 -Outdenting labels (-ola) has been made the default, in order to follow the
1239 perlstyle guidelines better. It's probably a good idea in general, but
1240 if you do not want this, use -nola in your .perltidyrc file.
1242 -Updated rules for padding logical expressions to include more cases.
1243 Thanks to Wolfgang Weisselberg for helpful discussions.
1245 -Added new flag -osbc (--outdent-static-block-comments) which will
1246 outdent static block comments by 2 spaces (or whatever -ci equals).
1247 Requested by Jon Robison.
1250 -Corrected a bug, introduced in the previous release, in which some
1251 closing side comments (-csc) could have incorrect text. This is
1252 annoying but will be correct the next time perltidy is run with -csc.
1254 -Implemented XHTML patch submitted by Ville Skyttä.
1256 -Fixed bug where whitespace was being removed between 'Bar' and '()'
1257 in a use statement like:
1261 Thanks to Ville Skyttä for reporting this.
1263 -Whenever possible, if a logical expression is broken with leading
1264 '&&', '||', 'and', or 'or', then the leading line will be padded
1265 with additional space to produce alignment. This has been on the
1266 todo list for a long time; thanks to Frank Steinhauer for reminding
1267 me to do it. Notice the first line after the open parens here:
1271 !param("rules.to.$linecount")
1272 && !param("rules.from.$linecount")
1273 && !param("rules.subject.$linecount")
1275 param("rules.fieldname.$linecount")
1276 && param("rules.fieldval.$linecount")
1278 && !param("rules.size.$linecount")
1279 && !param("rules.custom.$linecount")
1284 !param("rules.to.$linecount")
1285 && !param("rules.from.$linecount")
1286 && !param("rules.subject.$linecount")
1288 param("rules.fieldname.$linecount")
1289 && param("rules.fieldval.$linecount")
1291 && !param("rules.size.$linecount")
1292 && !param("rules.custom.$linecount")
1296 -Corrected a mistokenization of variables for a package with a name
1297 equal to a perl keyword. For example:
1301 sub qx{print "Hello from my::qx\n";}
1303 In this case, the leading 'my' was mistokenized as a keyword, and a
1304 space was being place between 'my' and '::'. This has been
1305 corrected. Thanks to Martin Sluka for discovering this.
1307 -A new flag -bol (--break-at-old-logic-breakpoints)
1308 has been added to control whether containers with logical expressions
1309 should be broken open. This is the default.
1311 -A new flag -bok (--break-at-old-keyword-breakpoints)
1312 has been added to follow breaks at old keywords which return lists,
1313 such as sort and map. This is the default.
1315 -A new flag -bot (--break-at-old-trinary-breakpoints) has been added to
1316 follow breaks at trinary (conditional) operators. This is the default.
1318 -A new flag -cab=n has been added to control breaks at commas after
1319 '=>' tokens. The default is n=1, meaning break unless this breaks
1320 open an existing on-line container.
1322 -A new flag -boc has been added to allow existing list formatting
1323 to be retained. (--break-at-old-comma-breakpoints). See updated manual.
1325 -A new flag -iob (--ignore-old-breakpoints) has been added to
1326 prevent the locations of old breakpoints from influencing the output
1329 -Corrected problem where nested parentheses were not getting full
1330 indentation. This has been on the todo list for some time; thanks
1331 to Axel Rose for a snippet demonstrating this issue.
1333 OLD: inner list is not indented
1337 $ret->name, $user->username, $user->host,
1338 $user->server->name, $user->nick, "H"
1346 $ret->name, $user->username, $user->host,
1347 $user->server->name, $user->nick, "H"
1351 -Code cleaned up by removing the following unused, undocumented flags.
1352 They should not be in any .perltidyrc files because they were just
1353 experimental flags which were never documented. Most of them placed
1354 artificial limits on spaces, and Wolfgang Weisselberg convinced me that
1355 most of them they do more harm than good by causing unexpected results.
1357 --maximum-continuation-indentation (-mci)
1358 --maximum-whitespace-columns
1359 --maximum-space-to-comment (-xsc)
1360 --big-space-jump (-bsj)
1362 -Pod file 'perltidy.pod' has been appended to the script 'perltidy', and
1363 Tidy.pod has been append to the module 'Tidy.pm'. Older MakeMaker's
1364 were having trouble.
1366 -A new flag -isbc has been added for more control on comments. This flag
1367 has the effect that if there is no leading space on the line, then the
1368 comment will not be indented, and otherwise it may be. If both -ibc and
1369 -isbc are set, then -isbc takes priority. Thanks to Frank Steinhauer
1370 for suggesting this.
1372 -A new document 'stylekey.pod' has been created to quickly guide new users
1373 through the maze of perltidy style parameters. An html version is
1374 on the perltidy web page. Take a look! It should be very helpful.
1376 -Parameters for controlling 'vertical tightness' have been added:
1377 -vt and -vtc are the main controls, but finer control is provided
1378 with -pvt, -pcvt, -bvt, -bcvt, -sbvt, -sbcvt. Block brace vertical
1379 tightness controls have also been added.
1380 See updated manual and also see 'stylekey.pod'. Simple examples:
1382 # perltidy -lp -vt=1 -vtc=1
1383 @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
1384 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
1386 # perltidy -lp -vt=1 -vtc=0
1387 @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
1388 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
1391 -Lists which do not format well in uniform columns are now better
1392 identified and formated.
1395 return $c->create( 'polygon', $x, $y, $x + $ruler_info{'size'},
1396 $y + $ruler_info{'size'}, $x - $ruler_info{'size'},
1397 $y + $ruler_info{'size'} );
1402 $x + $ruler_info{'size'},
1403 $y + $ruler_info{'size'},
1404 $x - $ruler_info{'size'},
1405 $y + $ruler_info{'size'}
1409 radlablist($f1, pad('Initial', $p), $b->{Init}->get_panel_ref, 'None ',
1410 'None', 'Default', 'Default', 'Simple', 'Simple');
1414 $b->{Init}->get_panel_ref,
1415 'None ', 'None', 'Default', 'Default', 'Simple', 'Simple');
1417 -Corrected problem where an incorrect html filename was generated for
1418 external calls to Tidy.pm module. Fixed incorrect html title when
1419 Tidy.pm is called with IO::Scalar or IO::Array source.
1421 -Output file permissons are now set as follows. An output script file
1422 gets the same permission as the input file, except that owner
1423 read/write permission is added (otherwise, perltidy could not be
1424 rerun). Html output files use system defaults. Previously chmod 0755
1425 was used in all cases. Thanks to Mark Olesen for bringing this up.
1427 -Missing semicolons will not be added in multi-line blocks of type
1428 sort, map, or grep. This brings perltidy into closer agreement
1429 with common practice. Of course, you can still put semicolons
1430 there if you like. Thanks to Simon Perreault for a discussion of this.
1432 -Most instances of extra semicolons are now deleted. This is
1433 particularly important if the -csc option is used. Thanks to Wolfgang
1434 Weisselberg for noting this. For example, the following line
1435 (produced by 'h2xs' :) has an extra semicolon which will now be
1438 BEGIN { plan tests => 1 };
1440 -New parameter -csce (--closing-side-comment-else-flag) can be used
1441 to control what text is appended to 'else' and 'elsif' blocks.
1442 Default is to just add leading 'if' text to an 'else'. See manual.
1444 -The -csc option now labels 'else' blocks with additinal information
1445 from the opening if statement and elsif statements, if space.
1446 Thanks to Wolfgang Weisselberg for suggesting this.
1448 -The -csc option will now remove any old closing side comments
1449 below the line interval threshold. Thanks to Wolfgang Weisselberg for
1452 -The abbreviation feature, which was broken in the previous version,
1453 is now fixed. Thanks to Michael Cartmell for noting this.
1455 -Vertical alignment is now done for '||=' .. somehow this was
1459 -This version uses modules for the first time, and a standard perl
1460 Makefile.PL has been supplied. However, perltidy may still be
1461 installed as a single script, without modules. See INSTALL for
1464 -The man page 'perl2web' has been merged back into the main 'perltidy'
1465 man page to simplify installation. So you may remove that man page
1466 if you have an older installation.
1468 -Added patch from Axel Rose for MacPerl. The patch prompts the user
1469 for command line arguments before calling the module
1470 Perl::Tidy::perltidy.
1472 -Corrected bug with '-bar' which was introduced in the previous
1473 version. A closing block brace was being indented. Thanks to
1474 Alexandros M Manoussakis for reporting this.
1476 -New parameter '--entab-leading-whitespace=n', or '-et=n', has been
1477 added for those who prefer tabs. This behaves different from the
1478 existing '-t' parameter; see updated man page. Suggested by Mark
1481 -New parameter '--perl-syntax-check-flags=s' or '-pcsf=s' can be
1482 used to change the flags passed to perltidy in a syntax check.
1483 See updated man page. Suggested by Mark Olesen.
1485 -New parameter '--output-path=s' or '-opath=s' will cause output
1486 files to be placed in directory s. See updated man page. Thanks for
1487 Mark Olesen for suggesting this.
1489 -New parameter --dump-profile (or -dpro) will dump to
1490 standard output information about the search for a
1491 configuration file, the name of whatever configuration file
1492 is selected, and its contents. This should help debugging
1493 config files, especially on different Windows systems.
1495 -The -w parameter now notes possible errors of the form:
1497 $comment = s/^\s*(\S+)\..*/$1/; # trim whitespace
1499 -Corrections added for a leading ':' and for leaving a leading 'tcsh'
1500 line untouched. Mark Olesen reported that lines of this form were
1501 accepted by perl but not by perltidy:
1503 : # use -*- perl -*-
1504 eval 'exec perl -wS $0 "$@"' # shell should exec 'perl'
1505 unless 1; # but Perl should skip this one
1507 Perl will silently swallow a leading colon on line 1 of a
1508 script, and now perltidy will do likewise. For example,
1509 this is a valid script, provided that it is the first line,
1512 : print "Hello World\n";
1514 Also, perltidy will now mark a first line with leading ':' followed by
1515 '#' as type SYSTEM (just as a #! line), not to be formatted.
1517 -List formatting improved for certain lists with special
1518 initial terms, such as occur with 'printf', 'sprintf',
1519 'push', 'pack', 'join', 'chmod'. The special initial term is
1520 now placed on a line by itself. For example, perltidy -gnu
1524 "C4", hex($SourceAddr[0]),
1525 hex($SourceAddr[1]), hex($SourceAddr[2]),
1531 hex($SourceAddr[0]), hex($SourceAddr[1]),
1532 hex($SourceAddr[2]), hex($SourceAddr[3]));
1536 @{$$self{states}}, '64', '66', '68',
1537 '70', '72', '74', '76',
1538 '78', '80', '82', '84',
1539 '86', '88', '90', '92',
1540 '94', '96', '98', '100',
1547 '64', '66', '68', '70', '72', '74', '76',
1548 '78', '80', '82', '84', '86', '88', '90',
1549 '92', '94', '96', '98', '100', '102', '104'
1552 -Lists of complex items, such as matricies, are now detected
1553 and displayed with just one item per row:
1556 $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new(
1557 [ 1, tan( deg2rad($a) ), 0 ], [ tan( deg2rad($b) ), 1, 0 ],
1562 $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new(
1563 [ 1, tan( deg2rad($a) ), 0 ],
1564 [ tan( deg2rad($b) ), 1, 0 ],
1568 -The perl syntax check will be turned off for now when input is from
1569 standard input or standard output. The reason is that this requires
1570 temporary files, which has produced far too many problems during
1571 Windows testing. For example, the POSIX module under Windows XP/2000
1572 creates temporary names in the root directory, to which only the
1573 administrator should have permission to write.
1575 -Merged patch sent by Yves Orton to handle appropriate
1576 configuration file locations for different Windows varieties
1577 (2000, NT, Me, XP, 95, 98).
1579 -Added patch to properly handle a for/foreach loop without
1580 parens around a list represented as a qw. I didn't know this
1581 was possible until Wolfgang Weisselberg pointed it out:
1583 foreach my $key qw\Uno Due Tres Quadro\ {
1587 But Perl will give a syntax error without the $ variable; ie this will
1590 foreach qw\Uno Due Tres Quadro\ {
1594 -Merged Windows version detection code sent by Yves Orton. Perltidy
1595 now automatically turns off syntax checking for Win 9x/ME versions,
1596 and this has solved a lot of robustness problems. These systems
1597 cannot reliably handle backtick operators. See man page for
1600 -Merged VMS filename handling patch sent by Michael Cartmell. (Invalid
1601 output filenames were being created in some cases).
1603 -Numerous minor improvements have been made for -lp style indentation.
1605 -Long C-style 'for' expressions will be broken after each ';'.
1607 'perltidy -gnu' gives:
1610 for ($status = $db->seq($key, $value, R_CURSOR()) ; $status == 0
1611 and $key eq $origkey ; $status = $db->seq($key, $value, R_NEXT()))
1614 for ($status = $db->seq($key, $value, R_CURSOR()) ;
1615 $status == 0 and $key eq $origkey ;
1616 $status = $db->seq($key, $value, R_NEXT()))
1618 -For the -lp option, a single long term within parens
1619 (without commas) now has better alignment. For example,
1623 $self->throw("Must specify a known host, not $location,"
1624 . " possible values ("
1625 . join (",", sort keys %hosts) . ")");
1628 $self->throw("Must specify a known host, not $location,"
1629 . " possible values ("
1630 . join (",", sort keys %hosts) . ")");
1633 -This version is about 20 percent faster than the previous
1634 version as a result of optimization work. The largest gain
1635 came from switching to a dispatch hash table in the
1638 -perltidy -html will check to see if HTML::Entities is
1639 installed, and if so, it will use it to encode unsafe
1642 -Added flag -oext=ext to change the output file extension to
1643 be different from the default ('tdy' or 'html'). For
1646 perltidy -html -oext=htm filename
1648 will produce filename.htm
1650 -Added flag -cscw to issue warnings if a closing side comment would replace
1651 an existing, different side comments. See the man page for details.
1652 Thanks to Peter Masiar for helpful discussions.
1654 -Corrected tokenization error of signed hex/octal/binary numbers. For
1655 example, the first hex number below would have been parsed correctly
1656 but the second one was not:
1657 if ( ( $tmp >= 0x80_00_00 ) || ( $tmp < -0x80_00_00 ) ) { }
1659 -'**=' was incorrectly tokenized as '**' and '='. This only
1660 caused a problem with the -extrude opton.
1662 -Corrected a divide by zero when -extrude option is used
1664 -The flag -w will now contain all errors reported by 'perl -c' on the
1665 input file, but otherwise they are not reported. The reason is that
1666 perl will report lots of problems and syntax errors which are not of
1667 interest when only a small snippet is being formatted (such as missing
1668 modules and unknown bare words). Perltidy will always report all
1669 significant syntax errors that it finds, such as unbalanced braces,
1670 unless the -q (quiet) flag is set.
1672 -Merged modifications created by Hugh Myers into perltidy.
1673 These include a 'streamhandle' routine which allows perltidy
1674 as a module to operate on input and output arrays and strings
1675 in addition to files. Documentation and new packaging as a
1676 module should be ready early next year; This is an elegant,
1677 powerful update; many thanks to Hugh for contributing it.
1680 -added a tentative patch which tries to keep any existing breakpoints
1681 at lines with leading keywords map,sort,eval,grep. The idea is to
1682 improve formatting of sequences of list operations, as in a schwartzian
1686 my @sorted = map { $_->[0] }
1687 sort { $a->[1] <=> $b->[1] }
1688 map { [ $_, rand ] } @list;
1692 map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, rand ] } @list;
1695 my @sorted = map { $_->[0] }
1696 sort { $a->[1] <=> $b->[1] }
1697 map { [ $_, rand ] } @list;
1699 The new alignment is not as nice as the input, but this is an improvement.
1700 Thanks to Yves Orton for this suggestion.
1702 -modified indentation logic so that a line with leading opening paren,
1703 brace, or square bracket will never have less indentation than the
1704 line with the corresponding opening token. Here's a simple example:
1708 -text => "New Document",
1709 -command => \&new_document
1715 Note how the closing ');' is lined up with the first line, even
1716 though it closes a paren in the 'pack' line. That seems wrong.
1720 -text => "New Document",
1721 -command => \&new_document
1727 This seems nicer: you can up-arrow with an editor and arrive at the
1728 opening 'pack' line.
1730 -corrected minor glitch in which cuddled else (-ce) did not get applied
1731 to an 'unless' block, which should look like this:
1739 Thanks to Jeremy Mates for reporting this.
1741 -The man page has been reorganized to parameters easier to find.
1743 -Added check for multiple definitions of same subroutine. It is easy
1744 to introduce this problem when cutting and pasting. Perl does not
1745 complain about it, but it can lead to disaster.
1747 -The command -pro=filename or -profile=filename may be used to specify a
1748 configuration file which will override the default name of .perltidyrc.
1749 There must not be a space on either side of the '=' sign. I needed
1750 this to be able to easily test perltidy with a variety of different
1751 configuration files.
1753 -Side comment alignment has been improved somewhat across frequent level
1754 changes, as in short if/else blocks. Thanks to Wolfgang Weisselberg
1755 for pointing out this problem. For example:
1758 if ( ref $self ) { # Called as a method
1761 else { # Regular procedure call
1767 if ( ref $self ) { # Called as a method
1770 else { # Regular procedure call
1775 -New command -ssc (--static-side-comment) and related command allows
1776 side comments to be spaced close to preceding character. This is
1777 useful for displaying commented code as side comments.
1779 -New command -csc (--closing-side-comment) and several related
1780 commands allow comments to be added to (and deleted from) any or all
1781 closing block braces. This can be useful if you have to maintain large
1782 programs, especially those that you didn't write. See updated man page.
1783 Thanks to Peter Masiar for this suggestion. For a simple example:
1788 if ( !defined( $_[0] ) ) {
1789 print("Hello, World\n");
1792 print( $_[0], "\n" );
1796 This added '## end sub foo' to the closing brace.
1797 To remove it, perltidy -ncsc.
1799 -New commands -ola, for outdenting labels, and -okw, for outdenting
1800 selected control keywords, were implemented. See the perltidy man
1801 page for details. Thanks to Peter Masiar for this suggestion.
1803 -Hanging side comment change: a comment will not be considered to be a
1804 hanging side comment if there is no leading whitespace on the line.
1805 This should improve the reliability of identifying hanging side comments.
1806 Thanks to Peter Masiar for this suggestion.
1808 -Two new commands for outdenting, -olq (outdent-long-quotes) and -olc
1809 (outdent-long-comments), have been added. The original -oll
1810 (outdent-long-lines) remains, and now is an abbreviation for -olq and -olc.
1811 The new default is just -olq. This was necessary to avoid inconsistency with
1812 the new static block comment option.
1814 -Static block comments: to provide a way to display commented code
1815 better, the convention is used that comments with a leading '##' should
1816 not be formatted as usual. Please see '-sbc' (or '--static-block-comment')
1817 for documentation. It can be deactivated with with -nsbc, but
1818 should not normally be necessary. Thanks to Peter Masiar for this
1821 -Two changes were made to help show structure of complex lists:
1822 (1) breakpoints are forced after every ',' in a list where any of
1823 the list items spans multiple lines, and
1824 (2) List items which span multiple lines now get continuation indentation.
1826 The following example illustrates both of these points. Many thanks to
1827 Wolfgang Weisselberg for this snippet and a discussion of it; this is a
1828 significant formatting improvement. Note how it is easier to see the call
1829 parameters in the NEW version:
1832 assert( __LINE__, ( not defined $check )
1835 or $check eq "old", "Error in parameters",
1836 defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef",
1837 defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef",
1838 defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef" );
1843 ( not defined $check )
1847 "Error in parameters",
1848 defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef",
1849 defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef",
1850 defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef"
1853 Another example shows how this helps displaying lists:
1856 %{ $self->{COMPONENTS} } = (
1858 { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 },
1860 { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 },
1863 The structure is clearer with the added indentation:
1866 %{ $self->{COMPONENTS} } = (
1868 { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 },
1870 { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 },
1873 -The structure of nested logical expressions is now displayed better.
1874 Thanks to Wolfgang Weisselberg for helpful discussions. For example,
1875 note how the status of the final 'or' is displayed in the following:
1879 and null( $op->sibling )
1880 and $op->ppaddr eq "pp_null"
1881 and class($op) eq "UNOP"
1882 and ( ( $op->first->ppaddr =~ /^pp_(and|or)$/
1883 and $op->first->first->sibling->ppaddr eq "pp_lineseq" )
1884 or ( $op->first->ppaddr eq "pp_lineseq"
1885 and not null $op->first->first->sibling
1886 and $op->first->first->sibling->ppaddr eq "pp_unstack" ) ) );
1891 and null( $op->sibling )
1892 and $op->ppaddr eq "pp_null"
1893 and class($op) eq "UNOP"
1896 $op->first->ppaddr =~ /^pp_(and|or)$/
1897 and $op->first->first->sibling->ppaddr eq "pp_lineseq"
1899 or ( $op->first->ppaddr eq "pp_lineseq"
1900 and not null $op->first->first->sibling
1901 and $op->first->first->sibling->ppaddr eq "pp_unstack" )
1905 -A break will always be put before a list item containing a comma-arrow.
1906 This will improve formatting of mixed lists of this form:
1910 'text', 225, 20, -text => 'A Simple Plot',
1918 -text => 'A Simple Plot',
1923 -For convenience, the command -dac (--delete-all-comments) now also
1924 deletes pod. Likewise, -tac (--tee-all-comments) now also sends pod
1925 to a '.TEE' file. Complete control over the treatment of pod and
1926 comments is still possible, as described in the updated help message
1929 -The logic which breaks open 'containers' has been rewritten to be completely
1930 symmetric in the following sense: if a line break is placed after an opening
1931 {, [, or (, then a break will be placed before the corresponding closing
1932 token. Thus, a container either remains closed or is completely cracked
1935 -Improved indentation of parenthesized lists. For example,
1940 atan2( $GPSTempCompLong - $GPSLongitude,
1941 $GPSLatitude - $GPSTempCompLat ) * 180 / 3.14159265 );
1944 $GPSCompCourse = int(
1946 $GPSTempCompLong - $GPSLongitude,
1947 $GPSLatitude - $GPSTempCompLat
1948 ) * 180 / 3.14159265
1951 Further improvements will be made in future releases.
1953 -Some improvements were made in formatting small lists.
1955 -Correspondence between Input and Output line numbers reported in a
1956 .LOG file should now be exact. They were sometimes off due to the size
1957 of intermediate buffers.
1959 -Corrected minor tokenization error in which a ';' in a foreach loop
1960 control was tokenized as a statement termination, which forced a
1973 foreach ( $i = 0 ; $i <= 10 ; $i += 2 ) {
1977 -Corrected a problem with reading config files, in which quote marks were not
1978 stripped. As a result, something like -wba="&& . || " would have the leading
1979 quote attached to the && and not work correctly. A workaround for older
1980 versions is to place a space around all tokens within the quotes, like this:
1983 -Removed any existing space between a label and its ':'
1986 This was necessary because the label and its colon are a single token.
1988 -Corrected tokenization error for the following (highly non-recommended)
1990 $user = @vars[1] / 100;
1992 -Resolved cause of a difference between perltidy under perl v5.6.1 and
1993 5.005_03; the problem was different behavior of \G regex position
1997 -Corrected a bug in which a break was not being made after a full-line
1998 comment within a short eval/sort/map/grep block. A flag was not being
1999 zeroed. The syntax error check catches this. Here is a snippet which
2000 illustrates the bug:
2003 #open Socket to Dispatcher
2004 $sock = &OpenSocket;
2007 The formatter mistakenly thought that it had found the following
2010 eval {#open Socket to Dispatcher$sock = &OpenSocket; };
2012 The patch fixes this. Many thanks to Henry Story for reporting this bug.
2014 -Changes were made to help diagnose and resolve problems in a
2016 (1) processing of command parameters has been into two separate
2017 batches so that any errors in a .perltidyrc file can be localized.
2018 (2) commands --help, --version, and as many of the --dump-xxx
2019 commands are handled immediately, without any command line processing
2021 (3) Perltidy will ignore any commands in the .perltidyrc file which
2022 cause immediate exit. These are: -h -v -ddf -dln -dop -dsn -dtt
2023 -dwls -dwrs -ss. Thanks to Wolfgang Weisselberg for helpful
2024 suggestions regarding these updates.
2026 -Syntax check has been reinstated as default for MSWin32 systems. This
2027 way Windows 2000 users will get syntax check by default, which seems
2028 like a better idea, since the number of Win 95/98 systems will be
2029 decreasing over time. Documentation revised to warn Windows 95/98
2030 users about the problem with empty '&1'. Too bad these systems
2031 all report themselves as MSWin32.
2034 -Fixed tokenization error in which a method call of the form
2038 got a space before the '::' like this:
2042 Thanks to David Holden for reporting this.
2044 -Added -html control over pod text, using a new abbreviation 'pd'. See
2045 updated perl2web man page. The default is to use the color of a comment,
2046 but italicized. Old .css style sheets will need a new line for
2047 .pd to use this. The old color was the color of a string, and there
2050 -.css lines are now printed in sorted order.
2052 -Fixed interpolation problem where html files had '$input_file' as title
2053 instead of actual input file name. Thanks to Simon Perreault for finding
2054 this and sending a patch, and also to Tobias Weber.
2056 -Breaks will now have the ':' placed at the start of a line,
2057 one per line by default because this shows logical structure
2058 more clearly. This coding has been completely redone. Some
2059 examples of new ?/: formatting:
2062 wantarray ? map( $dir::cwd->lookup($_)->path, @_ ) :
2063 $dir::cwd->lookup( $_[0] )->path;
2067 ? map( $dir::cwd->lookup($_)->path, @_ )
2068 : $dir::cwd->lookup( $_[0] )->path;
2074 } : { a => 6, b => 8 };
2082 : { a => 6, b => 8 };
2085 $self->note($self->{skip} ? "Hunk #$self->{hunk} ignored at 1.\n" :
2086 "Hunk #$self->{hunk} failed--$@");
2089 $self->note($self->{skip}
2090 ? "Hunk #$self->{hunk} ignored at 1.\n"
2091 : "Hunk #$self->{hunk} failed--$@");
2095 $opts{"t"} ? 'title' :
2096 $opts{"s"} ? 'subject' : $opts{"a"} ? 'author' : 'title';
2100 $opts{"t"} ? 'title'
2101 : $opts{"s"} ? 'subject'
2102 : $opts{"a"} ? 'author'
2105 You can use -wba=':' to recover the previous default which placed ':'
2106 at the end of a line. Thanks to Michael Cartmell for helpful
2107 discussions and examples.
2109 -Tokenizer updated to do syntax checking for matched ?/: pairs. Also,
2110 the tokenizer now outputs a unique serial number for every balanced
2111 pair of brace types and ?/: pairs. This greatly simplifies the
2114 -Long lines with repeated 'and', 'or', '&&', '||' will now have
2115 one such item per line. For example:
2118 if ( $opt_d || $opt_m || $opt_p || $opt_t || $opt_x
2119 || ( -e $archive && $opt_r ) )
2121 ( $pAr, $pNames ) = readAr($archive);
2130 || ( -e $archive && $opt_r ) )
2132 ( $pAr, $pNames ) = readAr($archive);
2136 if ( $vp->{X0} + 4 <= $x && $vp->{X0} + $vp->{W} - 4 >= $x
2137 && $vp->{Y0} + 4 <= $y && $vp->{Y0} + $vp->{H} - 4 >= $y )
2140 if ( $vp->{X0} + 4 <= $x
2141 && $vp->{X0} + $vp->{W} - 4 >= $x
2142 && $vp->{Y0} + 4 <= $y
2143 && $vp->{Y0} + $vp->{H} - 4 >= $y )
2145 -Long lines with multiple concatenated tokens will have concatenated
2146 terms (see below) placed one per line, except for short items. For
2151 "Device type:" . $ib->family . " ID:" . $ib->serial . " CRC:"
2152 . $ib->crc . ": " . $ib->model() . "\n";
2155 $report .= "Device type:"
2156 . $ib->family . " ID:"
2157 . $ib->serial . " CRC:"
2159 . $ib->crc . ": " . "\n";
2161 NOTE: at present 'short' means 8 characters or less. There is a
2162 tentative flag to change this (-scl), but it is undocumented and
2163 is likely to be changed or removed later, so only use it for testing.
2164 In the above example, the tokens " ID:", " CRC:", and "\n" are below
2167 -If a line which is short enough to fit on a single line was
2168 nevertheless broken in the input file at a 'good' location (see below),
2169 perltidy will try to retain a break. For example, the following line
2170 will be formatted as:
2173 or die "Cannot open $file ($!)";
2175 if it was broken in the input file, and like this if not:
2177 open SUM, "<$file" or die "Cannot open $file ($!)";
2179 GOOD: 'good' location means before 'and','or','if','unless','&&','||'
2181 The reason perltidy does not just always break at these points is that if
2182 there are multiple, similar statements, this would preclude alignment. So
2183 rather than check for this, perltidy just tries to follow the input style,
2184 in the hopes that the author made a good choice. Here is an example where
2185 we might not want to break before each 'if':
2187 ($Locale, @Locale) = ($English, @English) if (@English > @Locale);
2188 ($Locale, @Locale) = ($German, @German) if (@German > @Locale);
2189 ($Locale, @Locale) = ($French, @French) if (@French > @Locale);
2190 ($Locale, @Locale) = ($Spanish, @Spanish) if (@Spanish > @Locale);
2192 -Added wildcard file expansion for systems with shells which lack this.
2193 Now 'perltidy *.pl' should work under MSDOS/Windows. Thanks to Hugh Myers
2194 for suggesting this. This uses builtin glob() for now; I may change that.
2196 -Added new flag -sbl which, if specified, overrides the value of -bl
2197 for opening sub braces. This allows formatting of this type:
2203 if (!defined($_[0])) {
2204 print("Hello, World\n");
2210 Requested by Don Alexander.
2212 -Fixed minor parsing error which prevented a space after a $$ variable
2213 (pid) in some cases. Thanks to Michael Cartmell for noting this.
2218 -Improved line break choices 'and' and 'or' to display logic better.
2222 exists $self->{'build_dir'} and push @e,
2223 "Unwrapped into directory $self->{'build_dir'}";
2226 exists $self->{'build_dir'}
2227 and push @e, "Unwrapped into directory $self->{'build_dir'}";
2229 -Fixed error of multiple use of abbreviatioin '-dsc'. -dsc remains
2230 abbreviation for delete-side-comments; -dsm is new abbreviation for
2233 -Corrected and updated 'usage' help routine. Thanks to Slaven Rezic for
2236 -The default for Windows is, for now, not to do a 'perl -c' syntax
2237 check (but -syn will activate it). This is because of problems with
2238 command.com. James Freeman sent me a patch which tries to get around
2239 the problems, and it works in many cases, but testing revealed several
2240 issues that still need to be resolved. So for now, the default is no
2241 syntax check for Windows.
2243 -I added a -T flag when doing perl -c syntax check.
2244 This is because I test it on a large number of scripts from sources
2245 unknown, and who knows what might be hidden in initialization blocks?
2246 Also, deactivated the syntax check if perltidy is run as root. As a
2247 benign example, running the previous version of perltidy on the
2248 following file would cause it to disappear:
2251 print "Bye, bye baby!\n";
2255 The new version will not let that happen.
2257 -I am contemplating (but have not yet implemented) making '-lp' the
2258 default indentation, because it is stable now and may be closer to how
2259 perl is commonly formatted. This could be in the next release. The
2260 reason that '-lp' was not the original default is that the coding for
2261 it was complex and not ready for the initial release of perltidy. If
2262 anyone has any strong feelings about this, I'd like to hear. The
2263 current default could always be recovered with the '-nlp' flag.
2267 - sub definition names are now specially colored, red by default.
2268 The letter 'm' is used to identify them.
2269 - keyword 'sub' now has color of other keywords.
2270 - restored html keyword color to __END__ and __DATA__, which was
2271 accidentally removed in the previous version.
2273 -A new -se (--standard-error-output) flag has been implemented and
2274 documented which causes all errors to be written to standard output
2275 instead of a .ERR file.
2277 -A new -w (--warning-output) flag has been implemented and documented
2278 which causes perltidy to output certain non-critical messages to the
2279 error output file, .ERR. These include complaints about pod usage,
2280 for example. The default is to not include these.
2282 NOTE: This replaces an undocumented -w=0 or --warning-level flag
2283 which was tentatively introduced in the previous version to avoid some
2284 unwanted messages. The new default is the same as the old -w=0, so
2285 that is no longer needed.
2287 -Improved syntax checking and corrected tokenization of functions such
2288 as rand, srand, sqrt, ... These can accept either an operator or a term
2289 to their right. This has been corrected.
2291 -Corrected tokenization of semicolon: testing of the previous update showed
2292 that the semicolon in the following statement was being mis-tokenized. That
2293 did no harm, other than adding an extra blank space, but has been corrected.
2295 for (sort {strcoll($a,$b);} keys %investments) {
2299 -New syntax check: after wasting 5 minutes trying to resolve a syntax
2300 error in which I had an extra terminal ';' in a complex for (;;) statement,
2301 I spent a few more minutes adding a check for this in perltidy so it won't
2304 -The behavior of --break-before-subs (-bbs) and --break-before-blocks
2305 (-bbb) has been modified. Also, a new control parameter,
2306 --long-block-line-count=n (-lbl=n) has been introduced to give more
2307 control on -bbb. This was previously a hardwired value. The reason
2308 for the change is to reduce the number of unwanted blank lines that
2309 perltidy introduces, and make it less erratic. It's annoying to remove
2310 an unwanted blank line and have perltidy put it back. The goal is to
2311 be able to sprinkle a few blank lines in that dense script you
2312 inherited from Bubba. I did a lot of experimenting with different
2313 schemes for introducing blank lines before and after code blocks, and
2314 decided that there is no really good way to do it. But I think the new
2315 scheme is an improvement. You can always deactivate this with -nbbb.
2316 I've been meaning to work on this; thanks to Erik Thaysen for bringing
2319 -The .LOG file is seldom needed, and I get tired of deleting them, so
2320 they will now only be automatically saved if perltidy thinks that it
2321 made an error, which is almost never. You can still force the logfile
2322 to be saved with -log or -g.
2324 -Improved method for computing number of columns in a table. The old
2325 method always tried for an even number. The new method allows odd
2326 numbers when it is obvious that a list is not a hash initialization
2330 $name, $xsargs, $parobjs, $optypes,
2331 $hasp2child, $pmcode, $hdrcode, $inplacecode,
2332 $globalnew, $callcopy
2337 $name, $xsargs, $parobjs, $optypes, $hasp2child,
2338 $pmcode, $hdrcode, $inplacecode, $globalnew, $callcopy
2342 -I fiddled with the list threshold adjustment, and some small lists
2343 look better now. Here is the change for one of the lists in test file
2347 ("in", "in", "pt", "pt", "pc", "pi", "mm", "mm", "cm", "cm", "\\hsize", "%",
2348 "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%");
2352 "in", "in", "pt", "pt", "pc", "pi",
2353 "mm", "mm", "cm", "cm", "\\hsize", "%",
2354 "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%"
2357 -Improved -lp formatting at '=' sign. A break was always being added after
2358 the '=' sign in a statement such as this, (to be sure there was enough room
2359 for the parameters):
2364 $biblionumber, $constraint,
2368 The updated version doesn't do this unless the space is really needed:
2370 new: my $fee = CalcReserveFee(
2372 $biblionumber, $constraint,
2376 -I updated the tokenizer to allow $#+ and $#-, which seem to be new to
2377 Perl 5.6. Some experimenting with a recent version of Perl indicated
2378 that it allows these non-alphanumeric '$#' array maximum index
2379 varaibles: $#: $#- $#+ so I updated the parser accordingly. Only $#:
2380 seems to be valid in older versions of Perl.
2382 -Fixed a rare formatting problem with -lp (and -gnu) which caused
2383 excessive indentation.
2385 -Many additional syntax checks have been added.
2387 -Revised method for testing here-doc target strings; the following
2388 was causing trouble with a regex test because of the '*' characters:
2392 Perl seems to allow almost anything to be a here doc target, so an
2393 exact string comparison is now used.
2395 -Made update to allow underscores in binary numbers, like '0b1100_0000'.
2397 -Corrected problem with scanning certain module names; a blank space was
2398 being inserted after 'warnings' in the following:
2399 use warnings::register;
2400 The problem was that warnings (and a couple of other key modules) were
2401 being tokenized as keywords. They should have just been identifiers.
2403 -Corrected tokenization of indirect objects after sort, system, and exec,
2404 after testing produced an incorrect error message for the following
2406 print sort $sortsubref @list;
2408 -Corrected minor problem where a line after a format had unwanted
2409 extra continuation indentation.
2411 -Delete-block-comments (and -dac) now retain any leading hash-bang line
2413 -Update for -lp (and -gnu) to not align the leading '=' of a list
2414 with a previous '=', since this interferes with alignment of parameters.
2416 old: my $hireDay = new Date;
2423 new: my $hireDay = new Date;
2430 -Modifications made to display tables more compactly when possible,
2431 without adding lines. For example,
2433 '1', "I", '2', "II", '3', "III", '4', "IV",
2434 '5', "V", '6', "VI", '7', "VII", '8', "VIII",
2437 '1', "I", '2', "II", '3', "III",
2438 '4', "IV", '5', "V", '6', "VI",
2439 '7', "VII", '8', "VIII", '9', "IX"
2441 -Corrected minor bug in which -pt=2 did not keep the right paren tight
2442 around a '++' or '--' token, like this:
2444 for ($i = 0 ; $i < length $key ; $i++ )
2446 The formatting for this should be, and now is:
2448 for ($i = 0 ; $i < length $key ; $i++)
2450 Thanks to Erik Thaysen for noting this.
2452 -Discovered a new bug involving here-docs during testing! See BUGS.html.
2454 -Finally fixed parsing of subroutine attributes (A Perl 5.6 feature).
2455 However, the attributes and prototypes must still be on the same line
2459 -Corrected minor, uncommon bug found during routine testing, in which a
2460 blank got inserted between a function name and its opening paren after
2461 a file test operator, but only in the case that the function had not
2462 been previously seen. Perl uses the existence (or lack thereof) of
2463 the blank to guess if it is a function call. That is,
2464 if (-l pid_filename()) {
2466 if (-l pid_filename ()) {
2467 which is a syntax error if pid_filename has not been seen by perl.
2469 -If the AutoLoader module is used, perltidy will continue formatting
2470 code after seeing an __END__ line. Use -nlal to deactivate this feature.
2471 Likewise, if the SelfLoader module is used, perltidy will continue
2472 formatting code after seeing a __DATA__ line. Use -nlsl to
2473 deactivate this feature. Thanks to Slaven Rezic for this suggestion.
2475 -pod text after __END__ and __DATA__ is now identified by perltidy
2476 so that -dp works correctly. Thanks to Slaven Rezic for this suggestion.
2478 -The first $VERSION line which might be eval'd by MakeMaker
2479 is now passed through unchanged. Use -npvl to deactivate this feature.
2480 Thanks to Manfred Winter for this suggestion.
2482 -Improved indentation of nested parenthesized expressions. Tests have
2483 given favorable results. Thanks to Wolfgang Weisselberg for helpful
2487 -Fixed a very rare problem in which an unwanted semicolon was inserted
2488 due to misidentification of anonymous hash reference curly as a code
2489 block curly. (No instances of this have been reported; I discovered it
2490 during testing). A workaround for older versions of perltidy is to use
2493 -Added -icb (-indent-closing-brace) parameter to indent a brace which
2494 terminates a code block to the same level as the previous line.
2495 Suggested by Andrew Cutler. For example,
2504 -Rewrote error message triggered by an unknown bareword in a print or
2505 printf filehandle position, and added flag -w=0 to prevent issuing this
2506 error message. Suggested by Byron Jones.
2508 -Added modification to align a one-line 'if' block with similar
2509 following 'elsif' one-line blocks, like this:
2510 if ( $something eq "simple" ) { &handle_simple }
2511 elsif ( $something eq "hard" ) { &handle_hard }
2512 (Suggested by Wolfgang Weisselberg).
2515 -Eliminated all constants with leading underscores because perl 5.005_03
2516 does not support that. For example, _SPACES changed to XX_SPACES.
2517 Thanks to kromJx for this update.
2520 -the directory of test files has been moved to a separate distribution
2521 file because it is getting large but is of little interest to most users.
2522 For the current distribution:
2523 perltidy-20010701.tgz contains the source and docs for perltidy
2524 perltidy-20010701-test.tgz contains the test files
2526 -fixed bug where temporary file perltidy.TMPI was not being deleted
2527 when input was from stdin.
2529 -adjusted line break logic to not break after closing brace of an
2530 eval block (suggested by Boris Zentner).
2532 -added flag -gnu (--gnu-style) to give an approximation to the GNU
2533 style as sometimes applied to perl. The programming style in GNU
2534 'automake' was used as a guide in setting the parameters; these
2535 parameters will probably be adjusted over time.
2537 -an empty code block now has one space for emphasis:
2538 if ( $cmd eq "bg_untested" ) {} # old
2539 if ( $cmd eq "bg_untested" ) { } # new
2540 If this bothers anyone, we could create a parameter.
2542 -the -bt (--brace-tightness) parameter has been split into two
2543 parameters to give more control. -bt now applies only to non-BLOCK
2544 braces, while a new parameter -bbt (block-brace-tightness) applies to
2545 curly braces which contain code BLOCKS. The default value is -bbt=0.
2547 -added flag -icp (--indent-closing-paren) which leaves a statement
2548 termination of the form );, };, or ]; indented with the same
2549 indentation as the previous line. For example,
2551 @month_of_year = ( # default, or -nicp
2552 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
2556 @month_of_year = ( # -icp
2557 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
2561 -Vertical alignment updated to synchronize with tokens &&, ||,
2562 and, or, if, unless. Allowable space before forcing
2563 resynchronization has been increased. (Suggested by Wolfgang
2566 -html corrected to use -nohtml-bold-xxxxxxx or -nhbx to negate bold,
2567 and likewise -nohtml-italic-xxxxxxx or -nhbi to negate italic. There
2568 was no way to negate these previously. html documentation updated and
2569 corrected. (Suggested by Wolfgang Weisselberg).
2571 -Some modifications have been made which improve the -lp formatting in
2574 -Perltidy now retains or creates a blank line after an =cut to keep
2575 podchecker happy (Suggested by Manfred H. Winter). This appears to be
2576 a glitch in podchecker, but it was annoying.
2579 -Added -bli flag to give continuation indentation to braces, like this
2583 extra_indentation();
2586 -Corrected an error with the tab (-t) option which caused the last line
2587 of a multi-line quote to receive a leading tab. This error was in
2588 version 2001 06 08 but not 2001 04 06. If you formatted a script
2589 with -t with this version, please check it by running once with the
2590 -chk flag and perltidy will scan for this possible error.
2592 -Corrected an invalid pattern (\R should have been just R), changed
2593 $^W =1 to BEGIN {$^W=1} to use warnings in compile phase, and corrected
2594 several unnecessary 'my' declarations. Many thanks to Wolfgang Weisselberg,
2595 2001-06-12, for catching these errors.
2597 -A '-bar' flag has been added to require braces to always be on the
2598 right, even for multi-line if and foreach statements. For example,
2599 the default formatting of a long if statement would be:
2601 if ($bigwasteofspace1 && $bigwasteofspace2
2602 || $bigwasteofspace3 && $bigwasteofspace4)
2607 With -bar, the formatting is:
2609 if ($bigwasteofspace1 && $bigwasteofspace2
2610 || $bigwasteofspace3 && $bigwasteofspace4) {
2613 Suggested by Eli Fidler 2001-06-11.
2615 -Uploaded perltidy to sourceforge cvs 2001-06-10.
2617 -An '-lp' flag (--line-up-parentheses) has been added which causes lists
2618 to be indented with extra indentation in the manner sometimes
2619 associated with emacs or the GNU suggestions. Thanks to Ian Stuart for
2620 this suggestion and for extensive help in testing it.
2622 -Subroutine call parameter lists are now formatted as other lists.
2623 This should improve formatting of tables being passed via subroutine
2624 calls. This will also cause full indentation ('-i=n, default n= 4) of
2625 continued parameter list lines rather than just the number of spaces
2626 given with -ci=n, default n=2.
2628 -Added support for hanging side comments. Perltidy identifies a hanging
2629 side comment as a comment immediately following a line with a side
2630 comment or another hanging side comment. This should work in most
2631 cases. It can be deactivated with --no-hanging-side-comments (-nhsc).
2632 The manual has been updated to discuss this. Suggested by Brad
2633 Eisenberg some time ago, and finally implemented.
2636 -fixed problem with parsing command parameters containing quoted
2637 strings in .perltidyrc files. (Reported by Roger Espel Llima 2001-06-07).
2639 -added two command line flags, --want-break-after and
2640 --want-break-before, which allow changing whether perltidy
2641 breaks lines before or after any operators. Please see the revised
2642 man pages for details.
2644 -added system-wide configuration file capability.
2645 If perltidy does not find a .perltidyrc command line file in
2646 the current directory, nor in the home directory, it now looks
2647 for '/usr/local/etc/perltidyrc' and then for '/etc/perltidyrc'.
2648 (Suggested by Roger Espel Llima 2001-05-31).
2650 -fixed problem in which spaces were trimmed from lines of a multi-line
2651 quote. (Reported by Roger Espel Llima 2001-05-30). This is an
2652 uncommon situation, but serious, because it could conceivably change
2653 the proper function of a script.
2655 -fixed problem in which a semicolon was incorrectly added within
2656 an anonymous hash. (Reported by A.C. Yardley, 2001-5-23).
2657 (You would know if this happened, because perl would give a syntax
2658 error for the resulting script).
2660 -fixed problem in which an incorrect error message was produced
2661 after a version number on a 'use' line, like this ( Reported
2662 by Andres Kroonmaa, 2001-5-14):
2664 use CGI 2.42 qw(fatalsToBrowser);
2666 Other than the extraneous error message, this bug was harmless.
2669 -fixed serious bug in which the last line of some multi-line quotes or
2670 patterns was given continuation indentation spaces. This may make
2671 a pattern incorrect unless it uses the /x modifier. To find
2672 instances of this error in scripts which have been formatted with
2673 earlier versions of perltidy, run with the -chk flag, which has
2674 been added for this purpose (SLH, 2001-04-05).
2676 ** So, please check previously formatted scripts by running with -chk
2679 -continuation indentation has been reprogrammed to be hierarchical,
2680 which improves deeply nested structures.
2682 -fixed problem with undefined value in list formatting (reported by Michael
2685 -Switched to graphical display of nesting in .LOG files. If an
2686 old format string was "(1 [0 {2", the new string is "{{(". This
2687 is easier to read and also shows the order of nesting.
2689 -added outdenting of cuddled paren structures, like ")->pack(".
2691 -added line break and outdenting of ')->' so that instead of
2694 -text => "perltidy",
2695 -relief => 'ridge')->pack;
2697 the current default is:
2700 -text => "perltidy",
2704 (requested by Michael Langner 2001-03-31; in the future this could
2705 be controlled by a command-line parameter).
2707 -revised list indentation logic, so that lists following an assignment
2708 operator get one full indentation level, rather than just continuation
2709 indentation. Also corrected some minor glitches in the continuation
2712 -Fixed problem with unwanted continuation indentation after a blank line
2713 (reported by Erik Thaysen 2001-03-28):
2715 -minor update to avoid stranding a single '(' on one line
2718 -corrected serious error tokenizing filehandles, in which a sub call
2719 after a print or printf, like this:
2720 print usage() and exit;
2722 print usage () and exit;
2723 Unfortunately, this converts 'usage' to a filehandle. To fix this, rerun
2724 perltidy; it will look for this situation and issue a warning.
2726 -fixed another cuddled-else formatting bug (Reported by Craig Bourne)
2728 -added several diagnostic --dump routines
2730 -added token-level whitespace controls (suggested by Hans Ecke)
2733 -added support for special variables of the form ${^WANT_BITS}
2735 -space added between scalar and left paren in 'for' and 'foreach' loops,
2736 (suggestion by Michael Cartmell):
2738 for $i( 1 .. 20 ) # old
2739 for $i ( 1 .. 20 ) # new
2741 -html now outputs cascading style sheets (thanks to suggestion from
2744 -flags -o and -st now work with -html
2746 -added missing -html documentation for comments (noted by Alex Izvorski)
2748 -support for VMS added (thanks to Michael Cartmell for code patches and
2751 -v-strings implemented (noted by Hans Ecke and Michael Cartmell; extensive
2752 testing by Michael Cartmell)
2754 -fixed problem where operand may be empty at line 3970
2755 (\b should be just b in lines 3970, 3973) (Thanks to Erik Thaysen,
2756 Keith Marshall for bug reports)
2758 -fixed -ce bug (cuddled else), where lines like '} else {' were indented
2759 (Thanks to Shawn Stepper and Rick Measham for reporting this)
2762 -fixed undefined value in line 153 (only worked with -I set)
2763 (Thanks to Mike Stok, Phantom of the Opcodes, Ian Ehrenwald, and others)
2765 -fixed undefined value in line 1069 (filehandle problem with perl versions <
2766 5.6) (Thanks to Yuri Leikind, Mike Stok, Michael Holve, Jeff Kolber)
2769 -Initial announcement at freshmeat.net; started Change Log
2770 (Unfortunately this version was DOA, but it was fixed the next day)