[sf-perl] regular expression ?
David Alban
extasia at extasia.org
Mon Sep 26 13:32:32 PDT 2011
is there any appreciable loss (performance or otherwise) in compiling
one's regex's even if they don't end up being used in a loop or
frequently called subroutine? i do it as a matter of course.
also, i tend not to trust whitespace. for me this:
m/looking for some phrase/
would become:
m{ looking \s+ for \s+ some \s+ phrase }xms
i might even add the /i for case insensitivity.
2011/9/26 yary <not.com at gmail.com>:
>
> On Mon, Sep 26, 2011 at 3:41 PM, Francisco Obispo <fobispo at isc.org> wrote:
>>
>> And if the process is running continuously and matching several of these,
>> you might want to:
>>
>> my $patterm= qr/Thank you for your order:\s*(\d+)/;
>>
>> if ($text =~ m/$patterm/){
>> my $order_num=$1;
>> # do stuff with $order_num
>>
>> }
>
> I don't think that improves performance or readability- the reg exp would be
> compiled once at load time either way.
--
Live in a world of your own, but always welcome visitors.
***
Just say NO to a police state:
http://www.nytimes.com/2011/09/13/opinion/protect-our-right-to-anonymity.html
More information about the SanFrancisco-pm
mailing list