5

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?

DisgruntledGoat
  • 21,658
  • 5
  • 56
  • 101
Lèse majesté
  • 15,356
  • 39
  • 49

1 Answers1

5

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.

Dennis Williamson
  • 743
  • 1
  • 6
  • 11