It happened to me again. I though I was going to work out a small shortcut on the text interface command line (shell) and it would take me perhaps a couple of minutes. Instead, it became an extreme detour over two days of effort and I must have put at least 2 or 3 hours into it. In the end, the answer was "perl". So here's what happened.
BTW, I'd first thought to create this node in "Cool Uses For Perl" but there's something HTML-ish messing up the layout there. The page horizontal width is massively enlarged so that one has to scroll drastically to read nodes.
Good monks (nuns too), here's how it started. I had a snippet of data copied from a metacpan.org web page into the system clipboard. Here's the data:
CPAN::Meta ExtUtils::Builder ExtUtils::Builder::Compiler ExtUtils::Config ExtUtils::Helpers ExtUtils::InstallPaths Getopt::Long List::Util TAP::Harness
What I wanted was the transmogrification of this list of lines into a single line (spaces between module names, of course). What I then planned to do with with my string data (again, we're in the shell here) was to run cpanminus on the list, which btw are dependencies of the module Dist::Build, so that I'd be ready to install Dist::Build without having cpanm have to do the depends-on dance for me. Why would want to do that? Sometimes I want to open a shell in a module build dir and build by hand, for a few different reasons. In this case the goal of shaping that string of module names completely eclipsed the original intention. It became an obsession.
Here's how it unfolded. I went to the toolshed and first I grabbed the hoe (sed). I do things on the principle of finding the smallest, simplest tool to do the jobs, it's just a matter of personal preference to be that way. sed doesn't weight that much.
I don't have a record to show the reader, of exactly what my invocation of sed looked like, because I had an os crash/reboot that wiped out the bash history before it could be saved, but the result I eventually got looked like this:
TAP::HarnessstallPathspiler
I should note that sed scripts can become very elaborate and I am not now (and probably never was) a skilled sed user; I generally just find a matching or substitution expression that will accomplish what I want, and that's as far as it goes. I found some very elaborate sed scripting on Snark-Overflow that didn't work for me. I was starting to feel cursed.
If anyone can explain to me why I get that string, I'll be very satisfied.
Next I put the hoe back and grabbed the spade (tr). Once I read the help page for tr I worked out a command line, and what did I get?
TAP::HarnessstallPathspiler
That's right. The same damned mojibake mess.
The same when I went to the toolshed once more and selected the pitchfork (fmt). I'm not sure whether I've ever even used fmt before, I dutifully read the help page and tried. Aughhhhh. More mojibake.
OK, it's Perlmonks here and so you saw this coming: I put away the hand tools and rolled out the backhoe (perl). Now, I flatter myself that I know perl better than I know sed or fmt, and I wondered why it had taken me so long to turn to our finest data-munger.
Well, I still had the dreadful line at first,with perl (which was a little bit of a comfort because I had long since started to question my own sanity):
TAP::HarnessstallPathspiler
Here's one thing I tried with perl:
$ </dev/clipboard perl -e 'push @a,$_ while <>;chomp @a;print join(@a,q[ ])'Yep, same thing. But at last, I found the/a perl solution.
$ </dev/clipboard perl -0777 -e 'my ($l)=<>; $l=~s{.\cJ}[ ]g; print $l;'The obscure -0777 switch in that invocation turns on slurp mode so every line gets read at once, to the end of file.
The observant reader is perhaps wondering what's this /dev/clipboard. I'm working on Cygwin; that's a special device file that Cygwin makes available, that's all.
If there's a lesson to be learned here, it might be "use the tool you know best, first."
Thanks for reading, and I know some of you laughed in rueful recognition (because this sort of thing has happened to me before this time, too).
Dec 26, 2025 at 20:47 UTCA just machine to make big decisions
Programmed by fellows (and gals) with compassion and vision
We'll be clean when their work is done
We'll be eternally free yes, and eternally young
Donald Fagen —> I.G.Y.
(Slightly modified for inclusiveness)
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |