http://qs1969.pair.com?node_id=11121804


in reply to Re^8: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
in thread What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff

How often do you need to compress internal whitespace? Anyway. it is faster:

$ perl -MBenchmark=cmpthese -wE'my$x=join" "=>"",("abc")x5,"";say"s +ourc: |$x|";sub trim{join" ",split" ",$x};sub rgx{$x=~s/^\s+//r=~s/\s ++$//r=~s/\s\s+/ /gr};say "split: |",trim(),"|";say"regex: |",rgx(),"| +";cmpthese(-2,{splt=>\&trim,rgx=>\&rgx})' sourc: | abc abc abc abc abc | split: |abc abc abc abc abc| regex: |abc abc abc abc abc| Rate rgx splt rgx 506423/s -- -71% splt 1767763/s 249% --

Enjoy, Have FUN! H.Merijn
  • Comment on Re^9: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
  • Download Code

Replies are listed 'Best First'.
Re^10: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by Your Mother (Archbishop) on Sep 16, 2020 at 07:14 UTC

    I think I always want whitespace normalized. I can’t think of a case where it wouldn’t bother me, even if, as in HTML rendering defaults, it generally will not be apparent. Two spaces between words in a title or regular text is as much a typographical error as a misspelling.

Re^10: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by LanX (Saint) on Oct 02, 2020 at 12:09 UTC
    $ perl -MBenchmark=cmpthese -wE'my$x=join"    "=>"",("abc")x5,"";say"sourc: ... yadda yadda ...

    Sorry, but this overly wide code-line is breaking the formatting of most of the thread. (took a bit to find it too)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      strange, logging out showed proper wrapping of long lines.

      Not sure whats going wrong here, these are my Display Settings

      *Code Listing Settings* Code Wrapping Off [ ] Code Wrap Length [80] Auto Code Wrapping [x] Code Prefix [<font color="red"><i></i></font>]

      have to check my own CSS settings and other browsers.

      never mind! :)

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery