in reply to more efficient regular expression please
Probably slower than what you're using, but easier to understand (I hope):
for(my $str = 'vaction.msg'; $str; $str = substr($str, 1, length($str) +)) { $replace_on =~ s/$str//; }
Ahh, the rarely seen (around here, anyway) three-element form of for. I've tested this loop and it produces the strings correctly. I don't know if this exactly matches your needs, but you should be able to modify it easily enough.
Update: Forgot that you need to escape the '.' before it gets put in a regex, which complicates things a bit.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: more efficient regular expression please
by bart (Canon) on Jul 03, 2003 at 19:57 UTC |