in reply to regexp causes segfault
Do it C style using pos and substr. This is laser fast and tested to 40MB
# proof it behaves right, uncomment to see # $_ = " '==\\'==' '==5==' '\\'\\'' '\\'3' '\\'' '1' '' " x 2; $n = 40000000; $_ = "'" . "=" x $n . "'"; my @pos; while ( /(?<!\\)'/gc ) { push @pos, pos; } for ( my $i= 0; $i <@pos; $i +=2 ) { my $begin = $pos[$i]; my $end = $pos[$i+1]-1; my $str = substr $_, $begin, ($end -$begin); # check what we have found using test string commented out #print "$begin $end '$str'\n"; print length($str), "\n"; }
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: regexp causes segfault
by Anonymous Monk on Mar 06, 2003 at 01:29 UTC | |
|
Re: Re: regexp causes segfault
by shirkdog_perl (Beadle) on Mar 06, 2003 at 01:30 UTC | |
by tachyon (Chancellor) on Mar 06, 2003 at 03:35 UTC |