Wrapping Up

We’ve covered quite a lot in this chapter. We started with a hello world script, the simplest possible use of standard output. Then we looked at standard error, the other output stream, and how we could use it to distinguish between and treat separately two different sorts of output from the same program.

We learned the difference between print and puts, and then looked at a more advanced form of them both: printf, with its flexible and powerful format strings that can be used to format values, convert values from one type to another, and help us generate readable tabular data by aligning our columns for us.

Finally, we explored redirecting standard output from within our script, so that we could use ordinary output methods to write ...

Get Text Processing with Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.