http://www.perlmonks.org?node_id=1015378


in reply to Is there a module for object-oriented substring handling/substitution?

I am not aware of a module to do anything like that specifically, and doubt that one would be more speedy/useful in a general case than just doing regex substitutions directly. Strings in Perl are not just byte arrays like they are in many other languages, so you will likely not gain much by trying to treat them like one. That being said, I can think of reasons when you might want to do something like that anyway.

Many years ago I wrote a special purpose text editor in perl/Tk to help produce texts for Project Gutenberg. The perl/Tk text widget provides some basic search and replace functionality but has many limitations so I wrote something similar to what you are asking as a work around. It was not OO, and was pretty heavily tied to perl/Tk::Text, so it probably isn't useful as drop in code, but you might be able to glean some useful bits if you end up writing something yourself.

Be aware that I started writing this in the heady days when perl 5.6 reigned supreme and I was a perl newby, so many of the design decisions were questionable by modern standards. Also, I have not been associated with it since 2005 or so, so the codebase may have moved on. If you are still curious after all those caveats, the code is still available on sourceforge.

  • Comment on Re: Is there a module for object-oriented substring handling/substitution?