note
eyepopslikeamosquito
<P>
That reminds me of a Rosetta code problem I did a few years ago at Perl Monks.
</P>
<P>
<blockquote>
Write a Perl function to reverse a string of words.
For example, given an input string of:
<CODE>
" one two three four "
</CODE>
the function should produce:
<CODE>
"four three two one"
</CODE>
That is, the input string reversed word by word, with a single
space between each word and with no leading or trailing space.
You may assume the input string consists only of alphabetic
characters, spaces and tabs.
</blockquote>
</P>
<P>
When you've written your function, you can view many solutions to this problem in Perl and other languages at [id://589260].
</P>
<P>
Update: Two more.
</P>
<P>
Given an input string, for example <C>"ZBBBCZZ"</C>, produce a list, for example, <C>["Z", "BBB", "C", "ZZ"]</C>. That is, break the input string into pieces based on change of character. Solutions at [id://632023].
</P>
<P>
Given a list of strings, for example <CODE>("a", "bb", "c", "d", "e", "f", "g", "h")</CODE>,
and a chunksize, for example <C>3</C>, write a subroutine to return a multi-line string,
for example:
<CODE>
a bb c
d e f
g h
</CODE>
The output string must contain a single space between each array element and a newline every chunksize items.
Note that no trailing space is permitted on any line and
the last line must be properly newline-terminated.
Solutions at [id://861938].
</P>
864450
864460