Regular expressions should be familiar as they are used in many UNIX commands with grep being the best known
|
Consider the simple pattern /Fox/. We can write the PERL version of grep as follows: |
$line = 0; |
while (<>) { |
if ( /Fox/ ) {
|
} |
$line++; |
} |
Another familiar operator is s in sed (the batch or stream line editor) where |
s/Pat1/Pat2/; # substitutes Pat1 by Pat2 in each line |
We'll have more to say about the s operator later |