Your IP : 216.73.216.48
# $EPIC: copattern,v 1.3 2001/07/23 17:53:03 jnelson Exp $
Synopsis:
$copattern(<pattern> <var1> <var2>)
Technical:
* If the <pattern> argument is omitted the empty string is returned.
* If the <var1> argument is omitted the empty string is returned.
* If the <var2> argument is omitted the empty string is returned.
* <pattern> is taken to be a wildcard pattern
* <var1> and <var2> are taken to be lvals (names of ASSIGNs)
* <var1> and <var2> should each have the same number of words.
* For each set of words, one from $<var1> and one from $<var2>, in order,
if the word from $<var1> is matched by <pattern> then the corresponding
word from $<var2> shall be included in the return value.
* Formally, the return value is a list of words from $<var2> that
correspond in position to the words from $<var1> that are matched
by <pattern>.
* The principle behind this is similar to $pattern(), but the return
value is made up of the words from a different variable than the one
that you are matching against.
* Parsing ends whenever $<var1> or $<var2> run out of words, whichever
comes first.
* Double quoted words are honored, but the double quotes will be lost
in the return value.
Practical:
When you have two variables, one that contains a list of control data,
and another that contains a list of secondary data, and you wish to
retrieve the secondary data, but you need to do it based on a query of
the control data, you might use this function. One possible use might
be if one variable held your friends list, and another held their access
levels.
Returns:
The words from $<var2> that correspond to all of the words in $<var1>
that are matched by <pattern>.
Examples:
@ friends = [bob@foo.com tom@bar.com]
@ levels = [20 10]
$copattern(*@foo.com friends levels) returns "20"
$copattern(*@bar.com friends levels) returns "10"
$copattern(*@*.com friends levels) returns "20 10"
$copattern(*@*.net friends levels) returns "" (empty string)
See also:
match(6); word(6)