Wrapping Up
We’ve now further developed our text processing toolkit. No longer are we restricted to writing Ruby code to be executed in the form of scripts. By harnessing the power of Ruby’s interpreter and its -e flag, we can pass code to Ruby directly from the command line.
But Ruby goes even further than that to help us. We can use the -n and -p flags to loop automatically over the lines in standard input, and in the latter case automatically output it. These flags allow us to very straightforwardly write snippets of Ruby code that filter standard input, slotting neatly into text processing pipelines.
This allows us to write quick and straightforward snippets that solve both simple problems and exploratory ones. This way of processing standard ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access