I0 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; print doFunc( "AABBCC",0 ); print doFunc( "AAAABBBBCCCC",0 ); sub doFunc { my( $theParam,$depth) = @_; print STDERR "dofunc($theParam)\n"; my $re; $re = ${['(.+)\1']}[$depth]||'(.+)(\1)'; print STDERR join"\n", $theParam =~ /$re/g,''; $theParam =~ s/$re/&doFunc($1,$depth+1)/ge; ++$theParam; print STDERR "=$theParam\n"; return $theParam; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: recursive s///g core dumps
by boo_radley (Parson) on May 17, 2002 at 04:18 UTC | |
|
Re: recursive s///g core dumps
by educated_foo (Vicar) on May 17, 2002 at 03:40 UTC | |
by I0 (Priest) on May 17, 2002 at 04:42 UTC |