[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] REgular Expression for IP address



On Sat, 12 Feb 2000 10:22:26 -0500, Ronald J Kimball wrote:

>@IPN = split "\\.", $1;   # workable

Right. The string itself is backslash + dot.

>@IPN = split "\.", $1;    # also workable

WRONG. This is identical to ".".

 @IPN = split '\.' , $1;   # better

>@IPN = split /\./, $1;    # PREFERRED

Yup.

Note for Detlef: turning a string into a pattern happens in two steps.
Sterp one: the string is constructed from your source. So "\\." is
actually a string containing ONE backslash, and a dot.

Second, this string is compiled as a pattern. The important point is
that the STRING itself should look exactly like the PATTERN between
slashes, if you'd type it in directly into the script.

If you want alternative delimiters, prefix the pattern with "m". 

  @IPN = split m|\.|, $1;   # m|PATTERN|


-- 
	Bart.

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org