in reply to Re: Slowness when inserting into pre-extended array
in thread Slowness when inserting into pre-extended array
The /o modifier is not necessary, as the string to match is already a constant and is therefor already compiled at compile time. From perldoc perlop:$line=~/^(\S*) [0-9.]* (.*)$/o;
PATTERN may contain variables, which will be interpolated (and the pattern recompiled) every time the pattern search is evaluated, except for when the delimiter is a single quote. (Note that $(, $), and $| are not interpolated because they look like end-of-string tests.) If you want such a pattern to be compiled only once, add a "/o" after the trailing delimiter. This avoids expensive run-time recompilations, and is useful when the value you are interpolating won't change over the life of the script. However, mentioning "/o" constitutes a promise that you won't change the variables in the pattern. If you change them, Perl won't even notice.
Are you sure that the regex will always match? If not, you may introduce duplicates for each time there's no match. From perldoc perlre:my ($class, $feature_vector) = ($1, $2);
NOTE: failed matches in Perl do not reset the match variables, which makes easier to write code that tests for a series of more specific cases and remembers the best match.
Liz
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Slowness when inserting into pre-extended array
by ryangabbard (Initiate) on Jul 20, 2003 at 03:52 UTC | |
by tilly (Archbishop) on Jul 20, 2003 at 17:23 UTC |