Question/comment about cwm and builtin string handling

I'm looking at using cwm in the role of performing simple inferences in the 
area of network device management.  I've come across a very simple problem 
that may lead to a new area of cwm functionality (either:  maybe desirable, 
or present and unknown to me).

My problem is this:  given an IP address and standard form (n.n.n.n) and a 
subnet mask in the same form, I wish to construct the subnet broadcast 
address in the same form.  This involves a combination of string and 
arithmetic (or bitwise logical) operations.  I think I can probably bend 
the arithmetic stuff to do the necessary duties, but I see no way to get 
the required arithmetic values from the network address strings

I note that cwm has a builtin construct that allows one to assemble strings 
from a sequence of parts, but I'm not aware of anything that does the 
reverse.   A convenient function for decomposing a string might be 
something based on something like Python's regular expression match 
r.match(string).groups(None), returning a list of groups corresponding to 
pieces of a regular expression.  For cwm, I'm thinking of something like:

   ( stringval pattern ) string:matches ?groups

or

   ( stringval pattern ) string:matches ( ?group1 ?group2 ... ?groupn )

which is true if stringval matches pattern, and ?groups is bound to a list 
of substrings of stringval corresponding to groups in the regular 
expression.  I think this one feature would provide a flexible way to split 
string values in arbitrary ways.

#g


-------------------
Graham Klyne
<GK@NineByNine.org>

Received on Monday, 9 December 2002 16:59:59 UTC