From: Ævar Arnfjörð Bjarmason Date: Thu, 30 Sep 2010 13:43:06 GMT Subject: [PATCH 13/16] send-email: extract_valid_address use qr// regexes and /o Message-ID: <1285854189-10240-14-git-send-email-avarab@gmail.com> In-Reply-To: <1285854189-10240-1-git-send-email-avarab@gmail.com> Change the regex fragment in extract_valid_address to use the qr// syntax for compiled regexes, and when they're used add a /o flag so they're only compiled once for the lifetime of the program. Signed-off-by: Ævar Arnfjörð Bjarmason --- git-send-email.perl | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/git-send-email.perl b/git-send-email.perl index b87c3f2..47d86ad 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -777,11 +777,11 @@ our ($message_id, %mail, $subject, $reply_to, $references, $message, sub extract_valid_address { my $address = shift; - my $local_part_regexp = '[^<>"\s@]+'; - my $domain_regexp = '[^.<>"\s@]+(?:\.[^.<>"\s@]+)+'; + my $local_part_regexp = qr/[^<>"\s@]+/; + my $domain_regexp = qr/[^.<>"\s@]+(?:\.[^.<>"\s@]+)+/; # check for a local address: - return $address if ($address =~ /^($local_part_regexp)$/); + return $address if ($address =~ /^($local_part_regexp)$/o); $address =~ s/^\s*<(.*)>\s*$/$1/; if ($have_email_valid) { @@ -789,7 +789,7 @@ sub extract_valid_address { } else { # less robust/correct than the monster regexp in Email::Valid, # but still does a 99% job, and one less dependency - $address =~ /($local_part_regexp\@$domain_regexp)/; + $address =~ /($local_part_regexp\@$domain_regexp)/o; return $1; } } -- 1.7.3.159.g610493