in reply to Re: Re: Re: Re: Peeling the Peelings
in thread Peeling the Peelings
Somehow I introduced an error into the code. This is the code that produced the benckmark shown. The difference is the first condition on the while line. I'd did have to reformat the code when pasting to stop it wrapping as I edit my code using lines well over 100 chars. Quite how I managed to add the > 0 in there I can't explain. This does handle all cases. I'll update the original node to reflect the mistake.
sub buk2 { my( $s, $n ) = @_; my( $start, $stop ) = ( 0, length $s ); ($start,$stop) = ( 1 + index( $s, '(', $start ), rindex( $s, ')', $stop -1 ) ) while $n-- and index( $s, '(', $start +1 ) > 0; substr $s, $start, $stop - $start; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Re: Peeling the Peelings
by bobn (Chaplain) on Jul 03, 2003 at 23:17 UTC |