Going Deeper

In this lesson, I've given you the basics of regular expressions so you can get started, and tomorrow you'll learn even more uses of regular expressions. For more information about any of these things, the perlre man page can be quite enlightening. For this section, let's look at a few other features I haven't discussed elsewhere in this lesson.

More Uses of Patterns

At the start of this lesson, you learned about the =~ for matching patterns to scalar variables other than $_. In addition to =~, you can also use !~, like this:

$thing !~ = /pattern/;

!~ is the logical not version of =~; in other words, it will return true only if the pattern is NOT found in $thing.

Another useful function for patterns is the pos function, which works ...

Get Sams Teach Yourself Perl in 21 Days, Second Edition 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.