in reply to Implementing variable-width negative lookbehind assertions?
First, the regex2 sub doesn't have to use eval, as the normal closure mechanism combined with //o should give you the semantics you have now. Also, you're going to the trouble of initializing your returned count to zero, then if it stays zero, you're returning undef. Better just to leave it uninitialized and use ++ on it; the results will be as you want. Thus:
sub regex2 { my $pat = shift; sub { my $count; ++$count while /$pat/iogx; $count }; }
-- Chip Salzenberg, Free-Floating Agent of Chaos
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Implementing variable-width negative lookbehind assertions?
by tye (Sage) on Jun 24, 2001 at 10:57 UTC |