in reply to Computing Subsets

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.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Computing Subsets
by grandpascorpion (Initiate) on May 27, 2012 at 22:03 UTC
    Thanks Toby! I'll give this a whirl.