Some folks suggest that Perl regular expressions even represent a small programming
language of their own. When you open the perlrequick man page (a brief introduction
to regular expressions in Perl), this idea is reinforced by using a ???Hello World!??? example.
To find the word World in ???Hello World???, use this line in a Perl script:
print ???It matches\n??? if ???Hello World??? =~ /World/;
This script tells Perl to find (=~) the expression World in the Hello World string and then
print the words It matches with a newline (\n) if it is found.
Any scalar can be matched against a regular expression in a script. This offers a wealth of
possibilities to locate and manipulate data. The trick is learning the shorthand involved
in getting it. This shorthand includes the metacharacters that represent search terms and
operators. It??™s because regular expression patterns are made up of metacharacters that
some people find cryptic and difficult to decipher.
Table 30.4 shows you some of the primary metacharacters and their uses in Perl. If you
are familiar with regular expressions and wildcards in the shell or other applications,
watch carefully for differences in Perl??™s metacharacter usage.
Pages:
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172