Closed p5pRT closed 7 years ago
The first patch removes trailing space from perlop.pod while the second one convert "\t"s to spaces ("\x20") globally there.
Please consider applying them.
These commits can also be found here:
https://github.com/shlomif/perl/tree/shlomif-perlop-tabs-and-spaces-cleanup
I hereby disclaim any implicit or explicit copyright ownership on these changes and place them under your choice of Public Domain/CC-Zero/MIT-X11-licence/Same-terms-as-Perl/Artistic 2.0/Any other licence.
Regards\,
Shlomi Fish
--
Shlomi Fish http://www.shlomifish.org/ http://is.gd/htwEXQ - Integrating GNU Guile into GNU coreutils
The American Lottery: all you need is a dollar and a dream. We will take the dollar\, but you can keep the dream.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
X<"> X<""> @@ -2206,8 +2206,8 @@ A double-quoted, interpolated string. $_ .= qq (*** The previous line contains the naughty word "$1".\n) - if /\b(tcl|java|python)\b/i; # :-) - $baz = "\n"; # a one-character string + if /\b(tcl|java|python)\b/i; # :-) + $baz = "\n"; # a one-character string =item C/> X X<`> X<``> X @@ -2385,11 +2385,11 @@ character sets in full. Options: - c Complement the SEARCHLIST. - d Delete found but unreplaced characters. - s Squash duplicate replaced characters. - r Return the modified string and leave the original string - untouched. + c Complement the SEARCHLIST. + d Delete found but unreplaced characters. + s Squash duplicate replaced characters. + r Return the modified string and leave the original string + untouched. If the C modifier is specified, the I character set is complemented. If the C modifier is specified, any characters @@ -2409,15 +2409,15 @@ squashing character sequences in a class. Examples: - $ARGV[1] =~ tr/A-Z/a-z/; # canonicalize to lower case ASCII + $ARGV[1] =~ tr/A-Z/a-z/; # canonicalize to lower case ASCII - $cnt = tr/*/*/; # count the stars in $_ + $cnt = tr/*/*/; # count the stars in $_ - $cnt = $sky =~ tr/*/*/; # count the stars in $sky + $cnt = $sky =~ tr/*/*/; # count the stars in $sky - $cnt = tr/0-9//; # count the digits in $_ + $cnt = tr/0-9//; # count the digits in $_ - tr/a-zA-Z//s; # bookkeeper -> bokeper + tr/a-zA-Z//s; # bookkeeper -> bokeper ($HOST = $host) =~ tr/a-z/A-Z/; $HOST = $host =~ tr/a-z/A-Z/r; # same thing @@ -2425,13 +2425,13 @@ Examples: $HOST = $host =~ tr/a-z/A-Z/r # chained with s///r =~ s/:/ -p/r; - tr/a-zA-Z/ /cs; # change non-alphas to single space + tr/a-zA-Z/ /cs; # change non-alphas to single space @stripped = map tr/a-zA-Z/ /csr, @original; - # /r with map + # /r with map tr [\200-\377] - [\000-\177]; # wickedly delete 8th bit + [\000-\177]; # wickedly delete 8th bit If multiple transliterations are given for a character, only the first one is used: @@ -2496,11 +2496,11 @@ other quoting construct. Just as in the shell, a backslashed bareword following the C<<< << >>> means the same thing as a single-quoted string does: - $cost = <<'VISTA'; # hasta la ... + $cost = <<'VISTA'; # hasta la ... That'll be $10 please, ma'am. VISTA - $cost = <<\VISTA; # Same thing! + $cost = <<\VISTA; # Same thing! That'll be $10 please, ma'am. VISTA @@ -2681,7 +2681,7 @@ Thus: or: m/ - bar # NOT a comment, this slash / terminated m//! + bar # NOT a comment, this slash / terminated m//! /x do not form legal quoted expressions. The quoted part ends on the @@ -3004,17 +3004,17 @@ gives you standard input. The C<@ARGV> array is then processed as a list of filenames. The loop while (<>) { - ... # code for each line + ... # code for each line } is equivalent to the following Perl-like pseudo code: unshift(@ARGV, '-') unless @ARGV; while ($ARGV = shift) { - open(ARGV, $ARGV); - while ( ) { - ... # code for each line - } + open(ARGV, $ARGV); + while ( ) { + ... # code for each line + } } except that it isn't so cumbersome to say, and will actually work. @@ -3065,15 +3065,15 @@ If you want to pass switches into your script, you can use one of the C modules or put a loop on the front like this: while ($_ = $ARGV[0], /^-/) { - shift; + shift; last if /^--$/; - if (/^-D(.*)/) { $debug = $1 } - if (/^-v/) { $verbose++ } - # ... # other switches + if (/^-D(.*)/) { $debug = $1 } + if (/^-v/) { $verbose++ } + # ... # other switches } while (<>) { - # ... # code for each line + # ... # code for each line } The C<< <> >> symbol will return C for end-of-file only once. @@ -3108,15 +3108,15 @@ internal function directly as C , which is probably the right way to have done it in the first place.) For example: while (<*.c>) { - chmod 0644, $_; + chmod 0644, $_; } is roughly equivalent to: open(FOO, "echo *.c | tr -s ' \t\r\f' '\\012\\012\\012\\012'|"); while ( ) { - chomp; - chmod 0644, $_; + chomp; + chmod 0644, $_; } except that the globbing is actually done internally using the standard @@ -3171,7 +3171,7 @@ and this all reduces to one string internally. Likewise, if you say foreach $file (@filenames) { - if (-s $file > 5 + 100 * 2**16) { } + if (-s $file > 5 + 100 * 2**16) { } } the compiler precomputes the number which that expression @@ -3200,23 +3200,23 @@ The granularity for such extension or truncation is one or more bytes. # ASCII-based examples - print "j p \n" ^ " a h"; # prints "JAPH\n" - print "JA" | " ph\n"; # prints "japh\n" - print "japh\nJunk" & '_____'; # prints "JAPH\n"; - print 'p N$' ^ " E bitwise operation. You may explicitly show which type of operation you intend by using C<""> or C<0+>, as in the examples below. - $foo = 150 | 105; # yields 255 (0x96 | 0x69 is 0xFF) - $foo = '150' | 105; # yields 255 - $foo = 150 | '105'; # yields 255 - $foo = '150' | '105'; # yields string '155' (under ASCII) + $foo = 150 | 105; # yields 255 (0x96 | 0x69 is 0xFF) + $foo = '150' | 105; # yields 255 + $foo = 150 | '105'; # yields 255 + $foo = '150' | '105'; # yields string '155' (under ASCII) - $baz = 0+$foo & 0+$bar; # both ops explicitly numeric - $biz = "$foo" ^ "$bar"; # both ops explicitly stringy + $baz = 0+$foo & 0+$bar; # both ops explicitly numeric + $biz = "$foo" ^ "$bar"; # both ops explicitly stringy This somewhat unpredictable behavior can be avoided with the experimental "bitwise" feature, new in Perl 5.22. You can enable it via S ) forces it to treat its operands as strings: use experimental "bitwise"; - $foo = 150 | 105; # yields 255 (0x96 | 0x69 is 0xFF) - $foo = '150' | 105; # yields 255 - $foo = 150 | '105'; # yields 255 - $foo = '150' | '105'; # yields 255 - $foo = 150 |. 105; # yields string '155' (under ASCII) - $foo = '150' |. 105; # yields string '155' - $foo = 150 |.'105'; # yields string '155' - $foo = '150' |.'105'; # yields string '155' - - $baz = $foo & $bar; # both operands numeric - $biz = $foo ^. $bar; # both operands stringy + $foo = 150 | 105; # yields 255 (0x96 | 0x69 is 0xFF) + $foo = '150' | 105; # yields 255 + $foo = 150 | '105'; # yields 255 + $foo = '150' | '105'; # yields 255 + $foo = 150 |. 105; # yields string '155' (under ASCII) + $foo = '150' |. 105; # yields string '155' + $foo = 150 |.'105'; # yields string '155' + $foo = '150' |.'105'; # yields string '155' + + $baz = $foo & $bar; # both operands numeric + $biz = $foo ^. $bar; # both operands stringy The assignment variants of these operators (C<&= |= ^= &.= |.= ^.=>) behave likewise under the feature. @@ -3299,11 +3299,11 @@ decimal places. See Knuth, volume II, for a more robust treatment of this topic. sub fp_equal { - my ($X, $Y, $POINTS) = @_; - my ($tX, $tY); - $tX = sprintf("%.${POINTS}g", $X); - $tY = sprintf("%.${POINTS}g", $Y); - return $tX eq $tY; + my ($X, $Y, $POINTS) = @_; + my ($tX, $tY); + $tX = sprintf("%.${POINTS}g", $X); + $tY = sprintf("%.${POINTS}g", $Y); + return $tX eq $tY; } The POSIX module (part of the standard perl distribution) implements @@ -3330,10 +3330,10 @@ they're currently pretty slow. At the cost of some space and considerable speed, they avoid the normal pitfalls associated with limited-precision representations. - use 5.010; - use bigint; # easy interface to Math::BigInt - $x = 123456789123456789; - say $x * $x; + use 5.010; + use bigint; # easy interface to Math::BigInt + $x = 123456789123456789; + say $x * $x; +15241578780673678515622620750190521 Or with rationals: -- 2.3.2 ```
On Tue\, 21 Apr 2015 13:25:27 GMT\, shlomif@shlomifish.org wrote:
The first patch removes trailing space from perlop.pod while the second one convert "\t"s to spaces ("\x20") globally there.
Please consider applying them.
These commits can also be found here:
https://github.com/shlomif/perl/tree/shlomif-perlop-tabs-and-spaces- cleanup
Since I know that cleaning up trailing whitespace is less controversial than changing tabs to spaces (though I'd vote for that myself)\, I'm going to apply the first patch\, but not the second\, and then mark the ticket Resolved.
Pushed to blead in commit a727cfacf4b7894de3ae8c4b906a3bffccd751be.
Thank you very much. -- James E Keenan (jkeenan@cpan.org)
The RT System itself - Status changed from 'new' to 'open'
@jkeenan - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#124359 (status was 'resolved')
Searchable as RT124359$