This seems to work...
use Test::More tests => 3; my $x = "AB:APPLE:BOY:ZOO:ZOOM"; ok isSubset('APPLE:ZOO' => $x); ok !isSubset('BOY:GIRL' => $x); ok isSubset('AB:BOY:ZOOM' => $x); sub isSubset { my ($small, $big) = @_; $small =~ s{:}{:(?:[^:]+:)*}xg; return($big =~ /^(?:[^:]+:)*$small(?::[^:]+)*/); }
... but I'd generally go with an array/hash solution.
In reply to Re: Computing Subsets
by tobyink
in thread Computing Subsets
by grandpascorpion
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |