in reply to Re^2: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)
in thread Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)

well thanks, but it's destructive ...

YOU can do better! ;-)

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

  • Comment on Re^3: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)

Replies are listed 'Best First'.
Re^4: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)
by tybalt89 (Monsignor) on Oct 20, 2021 at 17:27 UTC
      Oh lord .... you are right!

      All praise the /r flag! :)

      And let's hope no one will ever stumble over the semipredicate whitespace you inject for splitting ;-)

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

        Instead of using a space, I'd use U+002063. It would work just as the name suggests: INVISIBLE SEPARATOR

        my @list = split m/\x{2063}/ => s{(.)\K(?!\1)}{\x{2063}}gr;

        And I agree that once you have learned about \K and /r you will you that over and over and over again.


        Enjoy, Have FUN! H.Merijn