Interpolation and Regular Expressions

Apress eBooks · 2006

In this chapter, we have explored two of Perl’s richest features—interpolation and regular expressions. We first examined the ways in which Perl performs the task of string interpolation, when interpolation occurs, and how to interpolate variables and code. We then looked at regular expressions, including the match, substitution, and split functions, and basic and advanced definition of search patterns. We saw how to match overlapping terms, compare greedy versus nongreedy matches, convert file wildcards into regular expressions, and match multiple times with the same pattern. We also looked at Perl’s advanced special patterns, techniques and strategies for writing efficient regular expressions, and how to debug a regular expression using Perl’s built-in regular expression tracer. We also looked at generating regular expressions, precompiling them with the qr operator, and checking their validity before trying to use them. Finally, we looked briefly at the transliteration function, which shares a great deal in common with the syntax of the match and substitution functions but turns out to have nothing to do with regular expressions.

Read the paper · More papers on PaperTik