… | |
… | |
25 | |
25 | |
26 | Find all potions with spell objects inside them in someones inventory: |
26 | Find all potions with spell objects inside them in someones inventory: |
27 | |
27 | |
28 | type=SPELL in type=POTION in inv |
28 | type=SPELL in type=POTION in inv |
29 | |
29 | |
30 | Find all potions inside someones inventory, or inside applied containers: |
30 | Find all scrolls inside someones inventory, or inside applied scroll |
|
|
31 | containers: |
31 | |
32 | |
32 | type=POTION also in type=CONTAINER and applied in inv |
33 | type=SCROLL also in applied type=CONTAINER race="scroll" in inv |
|
|
34 | |
|
|
35 | Find all unpaid items, anywhere, even deeply nested inside other items, in |
|
|
36 | the originator: |
|
|
37 | |
|
|
38 | unpaid also deep in inv of originator |
33 | |
39 | |
34 | =head1 MATCH EXPRESSIONS |
40 | =head1 MATCH EXPRESSIONS |
35 | |
41 | |
36 | =head2 STRUCTURE |
42 | =head2 STRUCTURE |
37 | |
43 | |
38 | The two main structures are the C<match>, which selects objects matching |
44 | The two main structures are the C<match>, which selects objects matching |
39 | various criteria, and the C<condition, which determines if an object |
45 | various criteria, and the C<condition, which determines if an object |
40 | matches some desired properties: |
46 | matches some desired properties: |
41 | |
47 | |
42 | condition |
48 | condition |
43 | condition in set |
49 | condition in set-modifier |
|
|
50 | condition of root-object |
44 | |
51 | |
45 | A C<cond> receives a set of "context objects" that it is applied to. This |
52 | A C<condition> receives a set of "context objects" that it is applied |
46 | is initially just one object - for altars, it is the object dropped on it, |
53 | to. This is initially just one object - by default, for altars, it is the |
47 | for pedestals, the object on top of it and so on. |
54 | object dropped on it, for pedestals, the object on top of it and so on. |
48 | |
55 | |
49 | This set of context objects can be modified in various ways, for example |
56 | This set of context objects can be modified in various ways, for example |
50 | by replacing it with the inventories of all objects, or all objects on the |
57 | by replacing it with the inventories of all objects, or all items on the |
51 | same mapspace, and so on, by using the C<in> operator: |
58 | same mapspace, and so on, by using the C<in> operator: |
52 | |
59 | |
53 | condition in inv |
60 | condition in inv |
|
|
61 | condition in map |
|
|
62 | |
|
|
63 | Also, besides the default root object where all this begins, you can start |
|
|
64 | elsewhere, for example in the I<originator> (usually the player): |
|
|
65 | |
54 | condition in inv in originator |
66 | condition in inv of originator |
55 | |
67 | |
56 | Once the set of context objects has been established, each object is |
68 | Once the final set of context objects has been established, each object |
57 | matched against the C<cond> expression. Sometimes the server is only |
69 | is matched against the C<condition>. |
58 | interested in knowing whether I<anything> matches, and sometimes the |
70 | |
59 | server is interested in I<all> objects that match. |
71 | Sometimes the server is only interested in knowing whether I<anything> |
|
|
72 | matches, and sometimes the server is interested in I<all> objects that |
|
|
73 | match. |
60 | |
74 | |
61 | =head2 OPERATORS |
75 | =head2 OPERATORS |
62 | |
76 | |
63 | =over 4 |
77 | =over 4 |
64 | |
78 | |
… | |
… | |
68 | expressions. C<not> negates the expression, and parentheses can be used to |
82 | expressions. C<not> negates the expression, and parentheses can be used to |
69 | group conditions. |
83 | group conditions. |
70 | |
84 | |
71 | Example: match applied weapons. |
85 | Example: match applied weapons. |
72 | |
86 | |
73 | type=WEAPON and applied |
87 | applied type=WEAPON |
74 | |
88 | |
75 | Example: match horns or rods. |
89 | Example: match horns or rods. |
76 | |
90 | |
77 | type=HORN or type=ROD |
91 | type=HORN or type=ROD |
78 | |
92 | |
… | |
… | |
84 | the match, the C<in> operator lets you look at other sets of objects, most |
98 | the match, the C<in> operator lets you look at other sets of objects, most |
85 | often the inventory. |
99 | often the inventory. |
86 | |
100 | |
87 | =over 4 |
101 | =over 4 |
88 | |
102 | |
89 | =item in object |
|
|
90 | |
|
|
91 | Replaces all objects by the default object - this is the object passed to |
|
|
92 | the match to match against by default. All matches have an explicit C<in |
|
|
93 | ctx> appended. |
|
|
94 | |
|
|
95 | This must be the last C<in> expression in a match. |
|
|
96 | |
|
|
97 | =item in source |
|
|
98 | |
|
|
99 | Replaces all objects by the source object - this object is sometimes |
|
|
100 | passed to matches and represents the object is the source of the action, |
|
|
101 | such as a rod or a potion when it is applied. Often, the I<source> is the |
|
|
102 | same as the I<originator>. |
|
|
103 | |
|
|
104 | This must be the last C<in> expression in a match. |
|
|
105 | |
|
|
106 | =item in originator |
|
|
107 | |
|
|
108 | Replaces all objects by the originator object - one step farther removed |
|
|
109 | than the I<source>, the I<originator> is sometimes passed to matches and |
|
|
110 | represents the original initiator of an action, most commonly a player or |
|
|
111 | monster. |
|
|
112 | |
|
|
113 | =item in self |
|
|
114 | |
|
|
115 | Replaces all objects by the object initiating/asking for the match - this |
|
|
116 | is basically always the object thatt he match expression is attached to. |
|
|
117 | |
|
|
118 | This must be the last C<in> expression in a match. |
|
|
119 | |
|
|
120 | =item in inv |
103 | =item in inv |
121 | |
104 | |
122 | Replaces all objects by their inventory. |
105 | Replaces all objects by their inventory. |
123 | |
106 | |
124 | Example: find all spell objects inside the object to be matched. |
107 | Example: find all spell objects inside the object to be matched. |
… | |
… | |
153 | |
136 | |
154 | Example: check if the context object I<is> a spell, or I<contains> a spell. |
137 | Example: check if the context object I<is> a spell, or I<contains> a spell. |
155 | |
138 | |
156 | type=SPELL also in inv |
139 | type=SPELL also in inv |
157 | |
140 | |
158 | =item repeatedly in ... |
141 | =item deep in ... |
159 | |
142 | |
160 | Repeats the operation as many times as possible. This can be used to |
143 | Repeats the operation as many times as possible. This can be used to |
161 | recursively look into objects. |
144 | recursively look into objects. |
162 | |
145 | |
163 | =item also repeatedly in ... |
146 | =item also deep in ... |
164 | |
147 | |
165 | C<also> and C<repeatedly> can be combined. |
148 | C<also> and C<deep> can be combined. |
166 | |
149 | |
167 | Example: check if there are any unpaid items in an inventory, |
150 | Example: check if there are any unpaid items in an inventory, |
168 | or in the inventories of the inventory objects, and so on. |
151 | or in the inventories of the inventory objects, and so on. |
169 | |
152 | |
170 | unpaid also repeatedly in inv |
153 | unpaid also deep in inv |
171 | |
154 | |
172 | Example: check if a object is inside a player. |
155 | Example: check if a object is inside a player. |
173 | |
156 | |
174 | type=PLAYER also repeatedly in env |
157 | type=PLAYER also deep in env |
175 | |
158 | |
176 | =back |
159 | =back |
|
|
160 | |
|
|
161 | =item of ... |
|
|
162 | |
|
|
163 | By default, all matches are applied to the "obviously appropriate" object, |
|
|
164 | such as the item dropped on a button or moving over a detector. This can |
|
|
165 | be changed to a number of other objects - not all of them are available |
|
|
166 | for each match (when not available, the match will simply fail). |
|
|
167 | |
|
|
168 | An C<of> term ends a match, nothing is allowed to follow. |
|
|
169 | |
|
|
170 | =over 4 |
|
|
171 | |
|
|
172 | =item of object |
|
|
173 | |
|
|
174 | Starts with the default object - this is the object passed to the match to |
|
|
175 | match against by default. Matches have an explicit C<of object> appended, |
|
|
176 | but submatches start at the current object, and in this case C<of object> |
|
|
177 | can be used to start at the original object once more. |
|
|
178 | |
|
|
179 | =item of source |
|
|
180 | |
|
|
181 | Starts with the I<source> object - this object is sometimes passed to |
|
|
182 | matches and represents the object that is the source of the action, such |
|
|
183 | as a rod or a potion when it is applied. Often, the I<source> is the same |
|
|
184 | as the I<originator>. |
|
|
185 | |
|
|
186 | =item of originator |
|
|
187 | |
|
|
188 | Starts with the I<originator> - one step farther removed than the |
|
|
189 | I<source>, the I<originator> is sometimes passed to matches and represents |
|
|
190 | the original initiator of an action, most commonly a player or monster. |
|
|
191 | |
|
|
192 | This object is often identical to the I<source> (e.g. when a player casts |
|
|
193 | a spell, the player is both source and originator). |
|
|
194 | |
|
|
195 | =item of self |
|
|
196 | |
|
|
197 | Starts with the object initiating/asking for the match - this is basically |
|
|
198 | always the object that the match expression is attached to. |
177 | |
199 | |
178 | =back |
200 | =back |
179 | |
201 | |
180 | =head2 EXPRESSIONS |
202 | =head2 EXPRESSIONS |
181 | |
203 | |
… | |
… | |
212 | =item { BLOCK } |
234 | =item { BLOCK } |
213 | |
235 | |
214 | You can specify perl code to execute by putting it inside curly |
236 | You can specify perl code to execute by putting it inside curly |
215 | braces. The last expression evaluated inside will become the result. |
237 | braces. The last expression evaluated inside will become the result. |
216 | |
238 | |
|
|
239 | The perlcode can access C<$_>, which rferes to the object currently being |
|
|
240 | matches, and the C<$object>, C<$self>, C<$source> and C<$originator>. |
|
|
241 | |
|
|
242 | Example: check whether the slaying field consists of digits only. |
|
|
243 | |
|
|
244 | { $_->slaying =~ /^\d+$/ } |
|
|
245 | |
217 | =item comparisons, <, <=, ==, =, !=, =>, > |
246 | =item comparisons, <, <=, ==, =, !=, =>, > |
218 | |
247 | |
219 | You can compare expressions against constants via any of these |
248 | You can compare expressions against constants via any of these |
220 | operators. If the constant is a string, then a string compare will be |
249 | operators. If the constant is a string, then a string compare will be |
221 | done, otherwise a numerical comparison is used. |
250 | done, otherwise a numerical comparison is used. |
… | |
… | |
243 | =item any |
272 | =item any |
244 | |
273 | |
245 | This simply evaluates to true, and simply makes matching I<any> object a |
274 | This simply evaluates to true, and simply makes matching I<any> object a |
246 | bit easier to read. |
275 | bit easier to read. |
247 | |
276 | |
248 | =item has(cond) |
277 | =item has(condition) |
249 | |
278 | |
250 | True iff the object has a matching inventory object. |
279 | True iff the object has a matching inventory object. |
251 | |
280 | |
252 | =item count(match) |
281 | =item count(match) |
253 | |
282 | |
254 | Number of matching objects - the context object for the C<match> are the |
283 | Number of matching objects - the context object for the C<match> is the |
255 | original context objects for the overall C<match>. # TODO bullshit |
284 | currently tested object - you can override this with an C<in object> for |
|
|
285 | example. |
256 | |
286 | |
257 | =item match(match) |
287 | =item match(match) |
258 | |
288 | |
259 | An independent match - unlike C<count>, it only matters whether the match |
289 | An independent match - semantics like C<count>, except it only matters |
260 | finds any object (which is faster). |
290 | whether the match finds any object (which is faster). |
|
|
291 | |
|
|
292 | =item dump |
|
|
293 | |
|
|
294 | Dumps the object to the server log when executed, and evaluates to true. |
|
|
295 | |
|
|
296 | Note that logical operations are short-circuiting, so this only dumps |
|
|
297 | potions: |
|
|
298 | |
|
|
299 | type=POTION and dump |
261 | |
300 | |
262 | =back |
301 | =back |
263 | |
302 | |
264 | =head2 GRAMMAR |
303 | =head2 GRAMMAR |
265 | |
304 | |
… | |
… | |
267 | module. It is meant to be easily readable by humans, not to implement it |
306 | module. It is meant to be easily readable by humans, not to implement it |
268 | exactly as-is. |
307 | exactly as-is. |
269 | |
308 | |
270 | # object matching and selecting |
309 | # object matching and selecting |
271 | |
310 | |
272 | match = set |
311 | match = chain |
|
|
312 | | chain 'of' root |
|
|
313 | root = 'object' | 'self' | 'source' | 'originator' |
|
|
314 | chain = condition |
273 | | match also rep 'in' set |
315 | | chain also deep 'in' set |
274 | also = nothing | 'also' |
316 | also = nothing | 'also' |
275 | rep = nothing | 'rep' | 'repeatedly' |
317 | deep = nothing | 'deep' |
276 | |
|
|
277 | set = 'inv' | 'env' | 'map' |
318 | set = 'inv' | 'env' | 'map' |
278 | | 'object' | 'source' | 'originator' | 'self' |
|
|
279 | |
319 | |
280 | empty = |
320 | empty = |
281 | |
321 | |
282 | # boolean matching condition |
322 | # boolean matching condition |
283 | |
323 | |
… | |
… | |
306 | special = <any ()-less "function"> |
346 | special = <any ()-less "function"> |
307 | |
347 | |
308 | constant = <number> | '"' <string> '"' | <uppercase cf::XXX name> |
348 | constant = <number> | '"' <string> '"' | <uppercase cf::XXX name> |
309 | args = <depends on function> |
349 | args = <depends on function> |
310 | |
350 | |
311 | TODO: repeatedly, env, contains, possbly matches |
351 | TODO: contains, matches, query_name, selling_price, buying_price? |
312 | |
352 | |
313 | =cut |
353 | =cut |
314 | |
354 | |
|
|
355 | =head2 PERL FUNCTIONS |
|
|
356 | |
|
|
357 | =over 4 |
|
|
358 | |
|
|
359 | =cut |
315 | |
360 | |
316 | package cf::match; |
361 | package cf::match; |
317 | |
362 | |
318 | use common::sense; |
363 | use common::sense; |
319 | |
364 | |
… | |
… | |
325 | |
370 | |
326 | { |
371 | { |
327 | package cf::match::exec; |
372 | package cf::match::exec; |
328 | |
373 | |
329 | use List::Util qw(first); |
374 | use List::Util qw(first); |
330 | |
|
|
331 | sub env_chain { |
|
|
332 | my @res; |
|
|
333 | push @res, $_ |
|
|
334 | while $_ = $_->env; |
|
|
335 | @res |
|
|
336 | } |
|
|
337 | |
375 | |
338 | package cf::match::parser; |
376 | package cf::match::parser; |
339 | |
377 | |
340 | use common::sense; |
378 | use common::sense; |
341 | |
379 | |
… | |
… | |
347 | has => sub { |
385 | has => sub { |
348 | 'first { ' . &condition . ' } $_->inv' |
386 | 'first { ' . &condition . ' } $_->inv' |
349 | }, |
387 | }, |
350 | count => sub { |
388 | count => sub { |
351 | local $all = 1; |
389 | local $all = 1; |
352 | '(scalar ' . &match . ')' |
390 | '(scalar ' . &match ('$_') . ')' |
353 | }, |
391 | }, |
354 | match => sub { |
392 | match => sub { |
355 | local $all = 0; |
393 | local $all = 0; |
356 | '(scalar ' . &match . ')' |
394 | '(scalar ' . &match ('$_') . ')' |
357 | }, |
395 | }, |
358 | ); |
396 | ); |
359 | |
397 | |
360 | our %special = ( |
398 | our %special = ( |
361 | any => sub { |
399 | any => sub { |
362 | 1 |
400 | 1 |
|
|
401 | }, |
|
|
402 | dump => sub { |
|
|
403 | 'do { |
|
|
404 | warn "cf::match::match dump:\n" |
|
|
405 | . "self: " . eval { $self->name } . "\n" |
|
|
406 | . $_->as_string; |
|
|
407 | 1 |
|
|
408 | }'; |
363 | }, |
409 | }, |
364 | ); |
410 | ); |
365 | |
411 | |
366 | sub constant { |
412 | sub constant { |
367 | ws; |
413 | ws; |
… | |
… | |
479 | sub condition { |
525 | sub condition { |
480 | my $res = factor; |
526 | my $res = factor; |
481 | |
527 | |
482 | while () { |
528 | while () { |
483 | ws; |
529 | ws; |
|
|
530 | |
|
|
531 | # first check some stop-symbols, so we don't have to backtrack |
484 | if (/\G(?=also\b|in\b|\)|$)/gc) { |
532 | if (/\G(?=also\b|deep\b|in\b|of\b\)|$)/gc) { |
485 | # early stop => faster and requires no backtracking |
|
|
486 | last; |
533 | last; |
|
|
534 | |
487 | } elsif (/\Gor\b/gc) { |
535 | } elsif (/\Gor\b/gc) { |
488 | $res .= " || "; |
536 | $res .= " || "; |
|
|
537 | |
489 | } else { |
538 | } else { |
490 | /\Gand\b/gc; |
539 | /\Gand\b/gc; |
491 | $res .= " && "; |
540 | $res .= " && "; |
492 | } |
541 | } |
493 | $res .= factor; |
542 | $res .= factor; |
… | |
… | |
495 | |
544 | |
496 | $res |
545 | $res |
497 | } |
546 | } |
498 | |
547 | |
499 | sub match { |
548 | sub match { |
500 | my $res; |
549 | my $default = shift; |
501 | |
550 | |
502 | my $also; # undef means first iteration |
551 | my $res = ($all ? " grep { " : " first {") . condition . " }"; |
|
|
552 | |
503 | while () { |
553 | while () { |
504 | if (/\G\s*(inv|env|map|object|subject|originator)\b/gc) { |
554 | ws; |
|
|
555 | |
|
|
556 | my $also = /\Galso\s+/gc + 0; |
|
|
557 | my $deep = /\Gdeep\s+/gc + 0; |
|
|
558 | |
|
|
559 | if (/\Gin\s+/gc) { |
|
|
560 | my $expand; |
|
|
561 | |
|
|
562 | if (/\G(inv|env|map)\b/gc) { |
505 | if ($1 eq "inv") { |
563 | if ($1 eq "inv") { |
506 | $res .= " map+(${also}\$_->inv),"; |
564 | $expand = "map \$_->inv,"; |
507 | } elsif ($1 eq "env") { |
565 | } elsif ($1 eq "env") { |
508 | $res .= " map+(${also}env_chain), "; # TODO |
566 | $expand = "map \$_->env // (),"; |
509 | } elsif ($1 eq "map") { |
567 | } elsif ($1 eq "map") { |
510 | $res .= " map+(${also}\$_->map->at (\$_->x, \$_->y)),"; |
568 | $expand = "map \$_->map->at (\$_->x, \$_->y),"; |
|
|
569 | } |
|
|
570 | } else { |
|
|
571 | $expand = "map \$_->inv, grep { " . condition . " }"; |
|
|
572 | } |
|
|
573 | |
|
|
574 | if ($also || $deep) { |
|
|
575 | $res .= " do {\n" |
|
|
576 | . " my \@res;\n"; |
|
|
577 | $res .= " while (\@_) {\n" if $deep; |
|
|
578 | $res .= " push \@res, \@_;\n" if $also; |
|
|
579 | $res .= " \@_ = $expand \@_;\n"; |
|
|
580 | $res .= " }\n" if $deep; |
|
|
581 | $res .= " (\@res, \@_)\n" |
|
|
582 | . "}"; |
|
|
583 | } else { |
|
|
584 | $res .= " $expand"; |
|
|
585 | } |
|
|
586 | } elsif (/\Gof\s+(self|object|source|originator)\b/gc) { |
|
|
587 | $also || $deep |
|
|
588 | and die "neither 'also' nor 'deep' can be used with 'of'\n"; |
|
|
589 | |
511 | } elsif ($1 eq "self") { |
590 | if ($1 eq "self") { |
512 | return "$res \$self"; |
591 | return "$res \$self // ()"; |
513 | } elsif ($1 eq "object") { |
592 | } elsif ($1 eq "object") { |
514 | last; # default |
593 | return "$res \$object"; |
515 | } elsif ($1 eq "source") { |
594 | } elsif ($1 eq "source") { |
516 | return "$res \$source"; |
595 | return "$res \$source // ()"; |
517 | } elsif ($1 eq "originator") { |
596 | } elsif ($1 eq "originator") { |
518 | return "$res \$originator"; |
597 | return "$res \$originator // \$source // ()"; |
519 | } |
598 | } |
520 | last unless /\G\s*in\b/gc; |
|
|
521 | } else { |
599 | } else { |
522 | $res .= " map+($also\$_->inv)," if defined $also; |
600 | return "$res $default"; |
523 | $res .= $all ? " grep { " : " first {"; |
|
|
524 | $res .= condition; |
|
|
525 | $res .= "}"; |
|
|
526 | |
|
|
527 | $also = /\G\s*also\b/gc ? '$_, ' : ''; |
|
|
528 | last unless /\G\s*in\b/gc; |
|
|
529 | } |
601 | } |
530 | } |
602 | } |
531 | |
|
|
532 | "$res \$object" |
|
|
533 | } |
603 | } |
534 | |
|
|
535 | } |
604 | } |
536 | |
605 | |
537 | sub parse($;$) { |
606 | sub parse($;$) { |
538 | local $_ = shift; |
607 | local $_ = shift; |
539 | local $all = shift; |
608 | local $all = shift; |
540 | |
609 | |
|
|
610 | my $res; |
|
|
611 | |
|
|
612 | eval { |
541 | my $res = cf::match::parser::match; |
613 | $res = cf::match::parser::match "\$object"; |
|
|
614 | |
|
|
615 | /\G\s*$/gc |
|
|
616 | or die "unexpected trailing characters after match\n"; |
|
|
617 | }; |
542 | |
618 | |
543 | if ($@) { |
619 | if ($@) { |
544 | my $ctx = 20; |
620 | my $ctx = 20; |
545 | my $str = substr $_, (List::Util::max 0, (pos) - $ctx), $ctx * 2; |
621 | my $str = substr $_, (List::Util::max 0, (pos) - $ctx), $ctx * 2; |
546 | substr $str, (List::Util::min $ctx, pos), 0, "<-- HERE -->"; |
622 | substr $str, (List::Util::min $ctx, pos), 0, "<-- HERE -->"; |
… | |
… | |
550 | } |
626 | } |
551 | |
627 | |
552 | $res |
628 | $res |
553 | } |
629 | } |
554 | |
630 | |
|
|
631 | if (0) {#d# |
|
|
632 | die parse 'applied', 1; |
|
|
633 | exit 0; |
|
|
634 | } |
|
|
635 | |
|
|
636 | =item cf::match::match $match, $object[, $self[, $source[, $originator]]] |
|
|
637 | |
|
|
638 | Compiles (and caches) the C<$match> expression and matches it against |
|
|
639 | the C<$object>. C<$self> should be the object initiating the match (or |
|
|
640 | C<undef>), C<$source> should be the actor/source and C<$originator> the |
|
|
641 | object that initiated the action (such as the player). C<$originator> |
|
|
642 | defaults to C<$source> when not given. |
|
|
643 | |
|
|
644 | In list context it finds and returns all matching objects, in scalar |
|
|
645 | context only a true or false value. |
|
|
646 | |
|
|
647 | =cut |
|
|
648 | |
555 | our %CACHE; |
649 | our %CACHE; |
556 | |
650 | |
557 | sub match($$$;$$) { |
651 | sub compile($$) { |
558 | my ($self, $match, $object, $source, $originator) = @_; |
652 | my ($match, $all) = @_; |
559 | my $all = wantarray+0; |
|
|
560 | |
|
|
561 | $originator ||= $source; |
|
|
562 | |
|
|
563 | &{ |
|
|
564 | $CACHE{"$all$match"} ||= do { |
|
|
565 | my $expr = parse $match, $all; |
653 | my $expr = parse $match, $all; |
566 | warn "$match,$all => $expr\n";#d# |
654 | warn "MATCH DEBUG $match,$all => $expr\n";#d# |
567 | $expr = eval "package cf::match::exec; sub { $expr }"; |
655 | $expr = eval " |
568 | die if $@; |
656 | package cf::match::exec; |
|
|
657 | sub { |
|
|
658 | my (\$object, \$self, \$source, \$originator) = \@_; |
569 | $expr |
659 | $expr |
570 | } |
660 | } |
571 | } |
661 | "; |
|
|
662 | die if $@; |
|
|
663 | |
|
|
664 | $expr |
572 | } |
665 | } |
573 | |
666 | |
574 | #match undef, "any", undef; |
667 | sub match($$;$$$) { |
575 | #exit 0; |
668 | my $match = shift; |
|
|
669 | my $all = wantarray+0; |
|
|
670 | |
|
|
671 | &{ |
|
|
672 | $CACHE{"$all$match"} ||= compile $match, $all |
|
|
673 | } |
|
|
674 | } |
|
|
675 | |
|
|
676 | #d# $::schmorp=cf::player::find "schmorp"& |
|
|
677 | #d# cf::match::match '', $::schmorp->ob |
|
|
678 | |
|
|
679 | |
|
|
680 | =back |
|
|
681 | |
|
|
682 | =head1 AUTHOR |
|
|
683 | |
|
|
684 | Marc Lehmann <schmorp@schmorp.de> |
|
|
685 | http://home.schmorp.de/ |
|
|
686 | |
|
|
687 | =cut |
576 | |
688 | |
577 | 1; |
689 | 1; |
578 | |
690 | |