Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I saw this bit of code on an old forum post:

SSLRequire %{HTTP_HOST} =~ m"\.secure\.powweb\.com"

And I was just wondering what the =~ and m" ... " meant. I've been searching online and in the Apache documentation for any mention of the equal-sign tilde operator, but I've found no mention of it. I know that some directives can take a tilde to use a regular expression, but I've never seen the m" ... " form used before.

What exactly is that m" ... " for? Where else would you see this form?

share|improve this question

migrated from serverfault.com Feb 8 '11 at 6:46

This question came from our site for professional system and network administrators.

1 Answer 1

up vote 4 down vote accepted

That is used for matching a regex in a string.

See man perlop:

Binary "=~" binds a scalar expression to a pattern match. Certain operations search or modify the string $_ by default. This operator makes that kind of operation work on some other string. The right argument is a search pattern, substitution, or transliteration. The left argument is what is supposed to be searched, substituted, or transliterated instead of the default $_.

and

m/PATTERN/msixpogc
/PATTERN/msixpogc
Searches a string for a pattern match, and in scalar context returns true if it succeeds, false if it fails. If no string is specified via the "=~" or "!~" operator, the $_ string is searched. (The string specified with "=~" need not be an lvalue--it may be the result of an expression evaluation, but remember the "=~" binds rather tightly.) See also perlre. See perllocale for discussion of additional considerations that apply when "use locale" is in effect.
...
If "/" is the delimiter then the initial "m" is optional. With the "m" you can use any pair of non-alphanumeric, non- whitespace characters as delimiters.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.