4 Feb Peteris Krumins has a new book, Perl One-Liners Explained. His new book is in the same style as his previous books on awk and sed. the gnarly Perl one-liner for accomplishing short tasks that do not need a complete The -e switch allows me to write Perl scripts directly on the command line. Perl One-liners. Perl one-liners are small and awesome Perl programs that fit in a . I explain this example in detail in one-liner (page 41), but basically you.

Author: Tygobei Tekus
Country: Mauritius
Language: English (Spanish)
Genre: Photos
Published (Last): 23 November 2005
Pages: 438
PDF File Size: 6.16 Mb
ePub File Size: 5.35 Mb
ISBN: 482-6-78958-935-7
Downloads: 25511
Price: Free* [*Free Regsitration Required]
Uploader: Dubar

I am under source control so there’s no harm in just operating right on the files.

Even the term “double spacing” isn’t quite definite, besides your meaning it also used for the practice of following the period after each sentence with two blanks. Interesting, didn’t know of that reason for using pkill – thanks. By using “-e” you can handily specify the program to execute on the command line.

Perl one-liners are small and awesome Perl programs that fit in a single line of code and they do one thing really well. Like -i it takes an argument, so should be used apart from other option sets: Fixed in the article. See more detailed category information.

Perl Regex One-Liner Cookbook

I was a bit surprised to see the amount of variation in the toolchain commands and flags command-line options across the tools on all those Unixes. Maybe I was a hit too excited about the perl part. I would think if you use Perl, you would probably use the one line from Perl is all.


I prefer one liners or scripts to any interactive mode. I ask this because your writing so logical.

My favorite perl one liner is a globbed search and replace. Also in the old days tools like sed and awk had more arbitrary limitations.

Thank you so much! Gorgor on Nov 30, The paragraphs file contains the -0 documentation from perlrunused in the following example:. The examples assume a Unix Bourne compatible shell such as zsh ; other command lines may require altering the quotes around the Perl code double quotes for Windowsor changes to support C-like shells cshtcsh. I went through all the one-liners in the article series, improved explanations, fixed mistakes and explainex, added a bunch of new one-liners, added an introduction to Perl one-liners and a new chapter on Perl’s special variables.

But didn’t know of xkill, thanks. It’s easier for me to add special corner cases to a perl one-liner, etc. Hi Stuart, I’ve been busy so forgive me my late reply.

How to Make Perl Regex One-Liners

So it one-linfrs pretty easy. For serious stuff I include real CSV libraries in the one liner to quote correctly etc. This is also a good use case for xargs, which makes the process even more flexible. See more detailed list of recent articles.


See more detailed list of all articles. Awk is a easier for me to remember than sed or perl, just because “sub” for one-linerss is in there: Sometimes I want to send a private message, or just thank for the great comment. How about extending the scope to “Whitespace Handling”?

Perl One Liners

See more detailed list of recent articles. Also if you’re interested, take a look at my other two e-books. And I actually think Perl is correct here and you should only need to escape those characters if you want literal matchesbut I have a weird environment Cygwin and it’s possible the sed build there is a little messed up. That doesn’t recurse into subdirectories.

The 1st one is called ” Awk One-Liners Explained ” and one-lniers 2nd one is called ” Sed One-Liners Explained ” They’re written in a similar style as this e-book and they teach practical Awk and Sed through many examples. If you go on at this pace it’ll take dozens of articles to cover the full range of one-liners. I think it’s stupid to say perl or even awk is obsolete. Ok, this is really tricky, ain’t it?

That said, pegl good context-free Perl one-liner can always be enjoyed on its mystifying own. Escape module from CPAN.