First page Back Continue Last page Overview Graphics
Recursive Patterns Using Eval
Old way – dynamic patterns
- our $pat;
- $pat = qr/\((?>(?>[^()]+)|(??{$pat}))*\)/x;
- if ('(x(x)y(x)x)' =~ /^($pat)$/){ ... }
Inherent problems
- Slow – requires the interpreter to resolve what $pat holds
- Fat – requires two patterns (inner and outer)
- Clumsy – requires use of global vars
- Ugly – pattern is not self contained. Pattern does not in of itself explain what it does.