in reply to Fell off the Llama
The exercise is dealing with regular expressions (which the book is calling patterns), which are a kind of string-description language.
The Perl operator for applying a regular expression to a string to see if it matches, is the "match operator", m//. The m is optional (and generally omitted) if slashes are used. The regular expression goes between the slashes. To see if $_ matches $pattern, we just do /$pattern/.
To see if the pattern in $what appears somewhere in $_ three times in a row, we can do /$what$what$what/, or /($what){3}/ for short.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fell off the Llama
by ysth (Canon) on Jun 25, 2004 at 05:02 UTC |