Hour 6. Pattern Matching

In the preceding hour, you learned about reading data from files. With that information, combined with your knowledge of scalars, arrays, and operators, you're prepared to manipulate that data to do what you want—almost. Sometimes the data in the file isn't formatted in an easy-to-use format that can be broken up with a simple split on spaces, or you have lines that contain data you're not interested in and want to edit out.

What you need is the ability to recognize patterns in the input stream, pick and choose data based on those patterns, and possibly edit the data to a more usable form. One of Perl's tools for performing this task is regular expressions. Throughout this text, the words regular expression and pattern ...

Get Sams Teach Yourself Perl in 24 Hours 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.