Andrew, here's your code:

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){

The part that's confusing you is the start of the regex.  If you
don't want to use // to do the pattern match, you use m with
the delimiters of your choice.  Here the coder is using m%regex%
to match the regular expression, i.e. the "%" is not the mod
operator, but the delimiter for the regex.

Also, \w is the 'word' character class.  In American, it matches
a-z, A-Z, 0-9, and _ .  That is, it is the same as writing a
character class like this: [A-Za-z0-9_] .  In other locales, there
will be additional letters which \w can match, but which listing
the letters could miss.  Putting a dash at the very beginning or
very end of a character class like [-A-Za-z0-9] ensures that it
is treated as a real dash, and not a range between two characters.
Since the pattern match has an x at the end to allow clearer
formatting, let's break it up like this:

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){

Now the pattern is a little clearer.  Match:
first the start of the line (the ^) with nothing before the next part,
then group without capturing in the $1 variable [this seems useless as written],
then capture into $1 the following:
at least one consecutive \w, 0 or more wordish things including - but *not* _,
followed by a period,
    followed by a word-charcter followed by at least one word-character [I don't
get why this is
    written this way - it could be done cleaner and probably written to run
faster]
or else capture into $1 the following:
2 to 4 consecutive numbers between 1 and 299 [yes, I know DNS goes up to 255
only and can have a
    legal 0 as in 127.0.0.1, but that's what the code will match - it ought to
be changed]
followed by in-addr.arpa in any case, followed by an optional period
and that has to end the variable.

The use of the construct "[Ii][Nn]-[Aa][Dd][Dd][Rr]\.[Aa][Rr][Pp][Aa]"
either shows a lack of knowledge about the /i option, or else shows a
sharp awareness about the slowness of /i vs. casing your letters in this
way.

HTH,
David
--
David Cassell, OAO                     [EMAIL PROTECTED]
Senior computing specialist
mathematical statistician



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

Reply via email to