Re: ?{ } block in regexes?
On Mon, Jul 11, 2005 at 00:03:08 -0400, Rick Delaney wrote: The trivial way: my $thing = qr/ (?{ $obj = create() } did you mean ?{ local $obj = create() }? -- () Yuval Kogman [EMAIL PROTECTED] 0xEBD27418 perl hacker /\ kung foo master: /me wields bonsai kittens: neeyah pgpyDWs0Rzm3J.pgp Description: PGP signature
Re: ?{ } block in regexes?
On Mon, Jul 11, 2005 at 05:00:45PM +0300, Yuval Kogman wrote: did you mean ?{ local $obj = create() }? Yes. -- Rick Delaney [EMAIL PROTECTED]
Re: ?{ } block in regexes?
On Sat, Jul 09, 2005 at 06:01:20AM +0300, Yuval Kogman wrote: How trivial is it to add a ?{ } block that is executed with the same semantics as ?{ }, except that instead of running when the engine matches over it, it gets run as the engine backtracks over it? my $thing = qr/ ?{ do_something() } ?{ undo_it() } $try_this_pattern /x; if $try_this_pattern fails, undo_it() is called to undo do_something(). The trivial way: my $thing = qr/ (?{ $obj = create() } $try_this_pattern /x; sub create { do_something(); bless [] } sub DESTROY { undo_it() } I don't think you'll have to look to hard to find problems with this approach but most of them will be related to the predictability of backtracking (due to optimizations, unspecified implementation, etc). Any addition to the RE engine would likely suffer from the same lack of predictability so would probably not be much of an improvement over the above code. -- Rick Delaney [EMAIL PROTECTED]
?{ } block in regexes?
How trivial is it to add a ?{ } block that is executed with the same semantics as ?{ }, except that instead of running when the engine matches over it, it gets run as the engine backtracks over it? my $thing = qr/ ?{ do_something() } ?{ undo_it() } $try_this_pattern /x; if $try_this_pattern fails, undo_it() is called to undo do_something(). -- () Yuval Kogman [EMAIL PROTECTED] 0xEBD27418 perl hacker /\ kung foo master: /me sneaks up from another MIME part: neeyah! pgpk19QbPRmXW.pgp Description: PGP signature