in reply to Pattern Matching with a Selected Sub-String

use 5.010; use strict; my $sample = "A-E-H-L"; my @sample_arr = split '-', $sample; my @options = ( "A-B-F-G-H-K-M", # idx = 0 "A-E-G-H-L", # idx = 1 "A-C-E-G-H-J-L", # idx = 2 "B-F-H-K", # idx = 3 "A-B-F-G-H-K-L", # idx = 4 "C-H" # idx = 5 ); my @matches = map { join '-', @$_ } grep { my $ok = 1; for my $s (@sample_arr) { next if $s ~~ @$_; $ok = 0; last }; $ok; } map { [split '-' ] } @options; say for @matches;
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'