Perl’s greatest strength is in text and file manipulation, which is accomplished by using the regular expression (regex) library. Regexes, which are quite different from the wildcard-handling and filename-expansion capabilities of the shell (see Chapter 12, “Automating Tasks and Shell Scripting”), allow complicated pattern matching and replacement to be done efficiently and easily.
For example, the following line of code replaces every occurrence of the string
bob or the string
fred in a line of text:
$string =~ s/bob|mary/fred/gi;
Without going into too many of the details, Table 37.7 explains what the preceding line says.
If you are interested in the ...