Text processing

This part is why Perl exists. Regular expressions with anchors and character classes, captures and named groups, substitution, split and join, grep and map, and a sort that can order records by any field.

5.1 Regular expressions: match and anchors the binding operators, anchors at both ends of a line, character classes and quantifiers Open 5.2 Captures and named groups pull a piece out of a match, read the numbered variables, and name a group in a long pattern Open 5.3 Substitution with s/// replace text, repeat with g, reuse a capture, run code with e, and translate characters with tr Open 5.4 split and join break a string into fields, limit the field count, cut on whitespace, and glue a list back together Open 5.5 grep and map filter a list with grep, transform it with map, chain the two, and count or find with List::Util Open 5.6 Sort and the Schwartzian transform sort as strings or numbers, order records by a field, sort a hash by value, and cache an expensive key Open

Lessons