Summary

Pattern matching and regular expressions are, arguably, Perl's most powerful feature. Whereas other languages might provide regular expression libraries or functions, pattern matching is intrinsic to Perl's operation and tightly bound to many other aspects of the language. Perl without regular expressions is just another funny-looking language. Perl with regular expressions is incredibly useful.

Today you learned all about patterns: building them, using them, saving bits of them, and putting them together with other parts of Perl. You learned about the various metacharacters you can use inside regular expressions: metacharacters for anchoring a pattern (^, $, B, ), for creating a character class ([] and [^]), for alternating between different patterns (|), and for matching multiples of characters (+, *, ?).

With that language for creating patterns, you can then apply those patterns to strings using the m// expression. By default, patterns affect the string stored in the $_ variable, unless you use the =~ operator to apply the pattern to any variable.

Tomorrow, we'll expand on what you've learned here, building on the patterns you've already learned with additional patterns and more and better ways to use those patterns.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset