|We don't bite newbies here... much|
EDIT: This code is wrong, see OP for correct version! Sorry...
It's much easier to develop one-liners on the command line because it can so rapidly scroll through history of revisions. I can get a few test runs deep into trouble fiddling around with it and get back to a working version by hitting the up arrow a few times. In many years I haven't found a more rapid, easier and fun way to explore and deploy the power of perl. After achieving my desire from the machine these mega one liners find themselves all sorts of places to extend the operating system with new commands and functions.
The way I'm posting them, dense and without triggering code wrap, makes it easy for me (and hopefully you) to copy directly from the webpage, to paste in a console. So you click download and see this gigantic one-liner that you want as a script? It depends on your operating system but for this script on Linux/Mac it goes something like this:
Control|Command + a to select all Control|Command + c to copy selected text In a terminal type: echo Type one space Control|Command + p to paste text Type: | perltidy -st >cpanexe; nano cpanexeHere's a handy blob of code to throw at a terminal that transforms itself into a proper script, saved to disk, opened in an editor. This can make any one liner into a script! Just echo a pasted one-liner to another one-liner via pipe and then pipe that to perltidy which you can direct to save a file and then open it in your favorite text editor:
I don't see the problem with dense code. It makes sense to me because that's how it gets created at the command line. Perlmonks understand it just as well as their spoken language so i don't understand the criticism or why we're constantly hounded by the cult of whitespace. Learn how to use perltidy and the rest of your operating system to make it do what you want instead of complaining. It's much more productive! ☺
This is a one-liner! A tidy 20 lines. It gets 29 things done with perl to do something impossible:
chomp join split grep for split grep push s for grep map substr length undef for if split push for else push map s print for sort cmp keys
STOP REINVENTING WHEELS, START BUILDING SPACE ROCKETS!—CPAN 🐪