OK, I just saw David Cassell wrote an excellent answer, but I had already
started composing this before leaving last night, so I'll send this off
anyway. Hope it gives a little additional insight.

Andrew Staples wrote:
> if ($zone !~ m%^(?:((?:\w[-A-Za-z0-9]*\.)+\w\w+)|((?:(?:[12]
> [0-9][0-9]|[1-9][0-9]?)\.){2,4})[Ii][Nn]-[Aa][Dd][Dd][Rr]\.[Aa]
> [Rr][Pp][Aa]\.?)$%x){

Let's split this up into multiple lines, to make it more legible:

if($zone !~ m%       # match -- using m%foo%x instead of /foo/x
    ^                # beginning of line
    (?:              # grouping (non-capturing) parentheses
      (              # capture to $1
        (?:          # grouping parentheses
          \w         # one "alphanumunder"
          [-A-Za-z0-9]*   # zero or more of hyphen, letter, or number
          \.         # followed by dot
        )+           # one or more of above
        \w\w+        # followed by two or more alphanumunders
      )              # end of capturing
      |              # alternative
      (              # capture to $2
        (?:          # grouping parens
          (?:        # more grouping parens
             [12][0-9][0-9]   # number from 100 to 299
             |       # or
             [1-9][0-9]?  # number 1-9, or 10-99
           )         # end of grouping
           \.        # one dot
        ){2,4}       # above two to four times
      )              # end of capturing
      [Ii][Nn]-[Aa][Dd][Dd][Rr]\.[Aa][Rr][Pp][Aa]
                     # 'in-addr.arpa', case insensitively
      \.?            # optional dot
    )                # end of grouping
    $                # end of line
%x) {                # note /x switch: "free-form" regexes allowed
                     # i.e. whitespace and comments are ignored
  # some processing
}


> m = treat the string as multiple lines (not sure why this 
> should happen)

No, that would be /m , as in an m after the match ends. Here you have a
match where you can choose your own delimiter. /foo/ = m!foo! = m{foo} =
m%foo% etc.

> %=mod, doesn't make sense to me

see above.

> ^ = beginning of string

yup.

> ?: = pattern match up to : *or* right operator

No: (?: .... ) are parentheses that are used for grouping but not for
capturing.

> \w[-A-Za-z0-9] = look for character that isn't alpha (is that 
> what the leading '-' is?) up to the first '.'

No. \w is a "word" character (letters, numbers, underscore) and a dash at
the beginning of a character class is just interpreted as a literal dash.
'Not a letter or digit' would be [^A-Za-z0-9] with a caret at the beginning.

> I pretty much get lost after that.  I think its verifying 
> that the the first 3 numbers must be 1 or 2, the second and
> third three must be 0-9.

No, it's two to four repetitions of (a number from 1 to 299, inclusive).

> I'm not sure what the '|' symbol is for either.

It separates alternatives: /foo|bar/ matches either foo or bar.

Hope this helps. You may also want to review perlop and perlre on the syntax
of m// and regular expressions, respectively.

Cheers,
Philip

---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to