Making a block of no strict 'vars' solves the problem. There I can assign the recursive regex to a proper ly declared variable, or call explicitly ($main::REparens).#!/usr/bin/perl -w use strict; my $input = "aa (bb cc) dd (ee (ff (gg) hh) jj) kk ((ll)) mm"; no strict 'vars'; # from $RE{balanced}{-parens=>'()'}; $REparens = qr/ (?:(?:(?:[(](?:(?>[^)(]+) |(??{$REparens}))*[)])) |(?:(?!)))/x; my $re = $REparens; use strict; print "input: $input\n"; while ($input =~ /\G(\w+|$re)\s*/gc) { print "$1\n" } __END__ output: aa (bb cc) dd (ee (ff (gg) hh) jj) kk ((ll)) mm
_ _ _ _ (_|| | |(_|>< _|
In reply to Re: A demanding parser (THE SOLUTION)
by gmax
in thread A demanding parser
by gmax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |