From: Steve Hancock Date: Mon, 21 Jan 2019 05:02:07 +0000 (-0800) Subject: Updated docs for RT #128265 X-Git-Tag: 20190601~21 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fffc2cbb7b9d10f24075dc7ee41ae70b533f3a51;p=perltidy.git Updated docs for RT #128265 --- diff --git a/bin/perltidy b/bin/perltidy index 9397b9a5..66dee3d1 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -3201,6 +3201,34 @@ available line length, the formatting will violate the requested brace style. If this happens, reformatting the script a second time should correct the problem. +Sometimes it might be desirable to convert a script to have one-line blocks +whenever possible. Although there is currently no flag for this, a simple +workaround is to execute perltidy twice, once with the flag B<-noadd-newlines> +and then once again with normal parameters, like this: + + cat infile | perltidy -nanl | perltidy >outfile + +When executed on this snippet + + if ( $? == -1 ) { + die "failed to execute: $!\n"; + } + if ( $? == -1 ) { + print "Had enough.\n"; + die "failed to execute: $!\n"; + } + +the result is + + if ( $? == -1 ) { die "failed to execute: $!\n"; } + if ( $? == -1 ) { + print "Had enough.\n"; + die "failed to execute: $!\n"; + } + +This shows that blocks with a single statement become one-line blocks. + + =item Debugging The following flags are available for debugging: diff --git a/docs/perltidy.html b/docs/perltidy.html index 44cbfcbf..37420dff 100644 --- a/docs/perltidy.html +++ b/docs/perltidy.html @@ -2205,7 +2205,7 @@

Finer control over blank placement can be achieved by using the individual parameters rather than the -kgb flag. The individual controls are as follows.

-

-kgbl=s or --keyword-group-blanks-list=s, where s is a quoted string, defines the set of keywords which will be formed into groups. The string is a space separated list of keywords. The default set is s="use require local our my", but any list of keywords may be used. Comment lines may also be included in a keyword group, even though they are not keywords. To include ordinary block comments, include the symbol BC. To include special block comments (which normally begin with '##'), include the symbol SBC.

+

-kgbl=s or --keyword-group-blanks-list=s, where s is a quoted string, defines the set of keywords which will be formed into groups. The string is a space separated list of keywords. The default set is s="use require local our my", but any list of keywords may be used. Comment lines may also be included in a keyword group, even though they are not keywords. To include ordinary block comments, include the symbol BC. To include static block comments (which normally begin with '##'), include the symbol SBC.

-kgbs=s or --keyword-group-blanks-size=s, where s is a string describing the number of consecutive keyword statements forming a group. If s is an integer then it is the minimum number required for a group. A maximum value may also be given with the format s=min.max, where min is the minimum number and max is the maximum number, and the min and max values are separated by one or more dots. No groups will be found if the maximum is less than the minimum. The maximum is unlimited if not given. The default is s=5. Some examples:

@@ -2486,6 +2486,30 @@

Occasionally, when one-line blocks get broken because they exceed the available line length, the formatting will violate the requested brace style. If this happens, reformatting the script a second time should correct the problem.

+

Sometimes it might be desirable to convert a script to have one-line blocks whenever possible. Although there is currently no flag for this, a simple workaround is to execute perltidy twice, once with the flag -noadd-newlines and then once again with normal parameters, like this:

+ +
     cat infile | perltidy -nanl | perltidy >outfile
+ +

When executed on this snippet

+ +
    if ( $? == -1 ) {
+        die "failed to execute: $!\n";
+    }
+    if ( $? == -1 ) {
+        print "Had enough.\n";
+        die "failed to execute: $!\n";
+    }
+ +

the result is

+ +
    if ( $? == -1 ) { die "failed to execute: $!\n"; }
+    if ( $? == -1 ) {
+        print "Had enough.\n";
+        die "failed to execute: $!\n";
+    }
+ +

This shows that blocks with a single statement become one-line blocks.

+
Debugging