in reply to Regular Expression Question
Once you've got your regex that you will be using to determine if a vowel/consonant combo is valid in your dictionary file, I would either pre-compile it using:
my $regex = qr/$string/; while (my $word = <DICT>) { chomp($word); if ($word =~ $regex) { $yep++; } }
or use the /o modifier (which assures the compiler that you won't be changing the contents of $string, or at least tells it not to bother recompiling):
while (my $word = <DICT>) { chomp($word); if ($word =~ /$string/o) { $yep++; } }
so that the regex won't be recompiled each time, as since there are variables in the regex, it forces a recompile, which will slow down your app quite a bit.
Just my two cents.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regular Expression Question
by Anonymous Monk on Apr 04, 2003 at 08:27 UTC | |
by perlguy (Deacon) on Apr 04, 2003 at 15:24 UTC | |
by Anonymous Monk on Apr 04, 2003 at 23:09 UTC |