With friends like these...
CRANK

C-o-rr-a-ll-i-n-gd-i-tt-o-e-dl-e-tt-e-r-sI was going to focus this week on the first task of the 20th Perl Weekly Challenge...but what can I say? The task was a break a string specified on the command-line into runs of identical characters: "toolless" → t oo ll e ss "subbookkeeper" → s u bb oo kk ee p e r "committee" → c o mm i tt ee But that’s utterly trivial in Perl 6: use v6.d; sub MAIN (\str) { .say for str.comb: /(.) $0*/ } And almost as easy in Perl 5:use v5.30;my $str = $ARGV[0]//die "Usage:\n $0 <str>\n";say $& while $str =~ /(.) \1*/gx;In both cases, the regex simply matches any character ((.)) and then rematches exactlythe same character ($0 or \1) zero-or-more times (*). Both match operations (str.comband $str =~) produce a list of the matched strings, each of which we then output(.say for... or say $& while...).As there’s not much more to say in either case, I instead turned my attention to the second…

blogs.perl.org
Related Topics: Perl