]> git.donarmstrong.com Git - perltidy.git/blobdiff - bin/perltidy
New upstream version 20170521
[perltidy.git] / bin / perltidy
index 08097638caec02ddc37d92b958d91e0fdb7e6f0f..174f792ab0b17455702263ac7971e4b07396fb4c 100755 (executable)
@@ -501,12 +501,30 @@ Perltidy will pass your string to perl with the exception that it will
 add a B<-c> and B<-x> if appropriate.  The F<.LOG> file will show
 exactly what flags were passed to perl.
 
+=item B<-xs>,   B<--extended-syntax>      
+
+A problem with formatting Perl code is that some modules can introduce new
+syntax.  This flag allows perltidy to handle certain common extensions
+to the standard syntax without complaint.  
+
+For example, without this flag a structure such as the following would generate
+a syntax error and the braces would not be balanced:
+
+    method deposit( Num $amount) {
+        $self->balance( $self->balance + $amount );
+    }
+
+This flag is enabled by default but it can be deactivated with B<-nxs>.
+Probably the only reason to deactivate this flag is to generate more diagnostic
+messages when debugging a script.
+
+
 =item B<-io>,   B<--indent-only>       
 
-This flag is used to deactivate all formatting and line break changes
+This flag is used to deactivate all whitespace and line break changes
 within non-blank lines of code.
 When it is in effect, the only change to the script will be
-to the indentation and blank lines.
+to the indentation and to the number of blank lines.
 And any flags controlling whitespace and newlines will be ignored.  You
 might want to use this if you are perfectly happy with your whitespace
 and line breaks, and merely want perltidy to handle the indentation.
@@ -520,6 +538,34 @@ B<--freeze-whitespace>.
 If you also want to keep your existing blank lines exactly
 as they are, you can add B<--freeze-blank-lines>. 
 
+With this option perltidy is still free to modify the indenting (and
+outdenting) of code and comments as it normally would.  If you also want to
+prevent long comment lines from being outdented, you can add either B<-noll> or
+B<-l=0>.
+
+Setting this flag will prevent perltidy from doing any special operations on
+closing side comments.  You may still delete all side comments however when
+this flag is in effect.
+
+
+=item B<-enc=s>,  B<--character-encoding=s>
+
+where B<s>=B<none> or B<utf8>.  This flag tells perltidy the character encoding
+of both the input and output character streams.  The value B<utf8> causes the
+stream to be read and written as UTF-8.  The value B<none> causes the stream to
+be processed without special encoding assumptions.  At present there is no
+automatic detection of character encoding (even if there is a C<'use utf8'>
+statement in your code) so this flag must be set for streams encoded in UTF-8.
+Incorrectly setting this parameter can cause data corruption, so please
+carefully check the output.
+
+The default is B<none>.  
+
+The abbreviations B<-utf8> or B<-UTF8> are equivalent to B<-enc=utf8>.
+So to process a file named B<file.pl> which is encoded in UTF-8 you can use:
+
+   perltidy -utf8 file.pl
+
 =item B<-ole=s>,  B<--output-line-ending=s>
 
 where s=C<win>, C<dos>, C<unix>, or C<mac>.  This flag tells perltidy
@@ -2285,7 +2331,7 @@ value specified on the B<-mbl=k> flag.
 =item B<-blbp=n>,  B<--blank-lines-before-packages=n>
 
 The parameter B<-blbp=n> requests that least B<n> blank lines precede a package
-which does not follow a comment.  The default is <-blbp=1>.  
+which does not follow a comment.  The default is B<-blbp=1>.  
 
 This parameter interacts with the value B<k> of the parameter
 B<--maximum-consecutive-blank-lines=k> (B<-mbl=k>) in the same way as described
@@ -2333,6 +2379,60 @@ This controls how often perltidy is allowed to add blank lines before
 certain block types (see previous section).  The default is 8.  Entering
 a value of B<0> is equivalent to entering a very large number.
 
+=item B<-blao=i> or B<--blank-lines-after-opening-block=i>
+
+This control places a minimum of B<i> blank lines B<after> a line which B<ends>
+with an opening block brace of a specified type.  By default, this only applies
+to the block of a named B<sub>, but this can be changed (see B<-blaol> below).
+The default is not to do this (B<i=0>).
+
+Please see the note below on using the B<-blao> and B<-blbc> options.
+
+=item B<-blbc=i> or B<--blank-lines-before-closing-block=i>
+
+This control places a minimum of B<i> blank lines B<before> a line which
+B<begins> with a closing block brace of a specified type.  By default, this
+only applies to the block of a named B<sub>, but this can be changed (see
+B<-blbcl> below).  The default is not to do this (B<i=0>).
+
+=item B<-blaol=s> or B<--blank-lines-after-opening-block-list=s>
+
+The parameter B<s> is a list of block type keywords to which the flag B<-blao>
+should apply.  The section L<"Specifying Block Types"> explains how to list
+block types.
+
+=item B<-blbcl=s> or B<--blank-lines-before-closing-block-list=s>
+
+This parameter is a list of block type keywords to which the flag B<-blbc>
+should apply.  The section L<"Specifying Block Types"> explains how to list
+block types.
+
+=item Note on using the B<-blao> and B<-blbc> options.
+
+These blank line controls introduce a certain minimum number of blank lines in
+the text, but the final number of blank lines may be greater, depending on
+values of the other blank line controls and the number of old blank lines.  A
+consequence is that introducing blank lines with these and other controls
+cannot be exactly undone, so some experimentation with these controls is
+recommended before using them.
+
+For example, suppose that for some reason we decide to introduce one blank
+space at the beginning and ending of all blocks.  We could do
+this using
+
+  perltidy -blao=2 -blbc=2 -blaol='*' -blbcl='*' filename
+
+Now suppose the script continues to be developed, but at some later date we
+decide we don't want these spaces after all. we might expect that running with
+the flags B<-blao=0> and B<-blbc=0> will undo them.  However, by default
+perltidy retains single blank lines, so the blank lines remain.  
+
+We can easily fix this by telling perltidy to ignore old blank lines by
+including the added parameter B<-kbl=0> and rerunning. Then the unwanted blank
+lines will be gone.  However, this will cause all old blank lines to be
+ignored, perhaps even some that were added by hand to improve formatting. So
+please be cautious when using these parameters.
+
 =item B<-mbl=n> B<--maximum-consecutive-blank-lines=n>   
 
 This parameter specifies the maximum number of consecutive blank lines which
@@ -2577,8 +2677,8 @@ are preceded by the name of the alias (without leading dashes), like this:
        }
 
 where B<newword> is the abbreviation, and B<opt1>, etc, are existing parameters
-I<or other abbreviations>.  The main syntax requirement is that
-the new abbreviation must begin on a new line.
+I<or other abbreviations>.  The main syntax requirement is that the new
+abbreviation along with its opening curly brace must begin on a new line.
 Space before and after the curly braces is optional.
 For a
 specific example, the following line
@@ -2981,6 +3081,9 @@ of the keyword which introduces that block, such as B<if>, B<else>, or B<sub>.
 An exception is a labeled block, which has no keyword, and should be specified
 with just a colon.  To specify all blocks use B<'*'>.
 
+The keyword B<sub> indicates a named sub.  For anonymous subs, use the special
+keyword B<asub>.
+
 For example, the following parameter specifies C<sub>, labels, C<BEGIN>, and
 C<END> blocks:
 
@@ -3093,32 +3196,19 @@ perlstyle(1), Perl::Tidy(3)
 
 =head1 VERSION
 
-This man page documents perltidy version 20130922.
-
-=head1 CREDITS
-
-Michael Cartmell supplied code for adaptation to VMS and helped with
-v-strings.
-
-Yves Orton supplied code for adaptation to the various versions
-of Windows. 
-
-Axel Rose supplied a patch for MacPerl.
+This man page documents perltidy version 20170521.
 
-Hugh S. Myers designed and implemented the initial Perl::Tidy module interface. 
+=head1 BUG REPORTS
 
-Many others have supplied key ideas, suggestions, and bug reports;
-see the CHANGES file.
+A list of current bugs and issues can be found at the CPAN site
 
-=head1 AUTHOR
+     https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy
 
-  Steve Hancock
-  email: perltidy at users.sourceforge.net
-  http://perltidy.sourceforge.net
+To report a new bug or problem, use the link on this page.  
 
 =head1 COPYRIGHT
 
-Copyright (c) 2000-2012 by Steve Hancock
+Copyright (c) 2000-2017 by Steve Hancock
 
 =head1 LICENSE