in reply to Partial Searches Against Multiple Wildcards

I was looking for a way to solve this without generating a regex. This is the best I have found so far.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11156323 use warnings; my %data = map { (split)[1] => $_ } <DATA>; for my $searchfor ( qw( 940 ABFD-1 ABFD1 D7RD DD482 ) ) { print "\n$searchfor\n"; print ' ' x 8, $data{$_} for grep match($searchfor, $_), sort keys +%data; } sub match { use feature 'bitwise'; my ($match, $to) = map tr/*-/\0/dr, @_; my $length = length $match; return $to =~ /(?=(.{$length})) (??{ ($match ^. $1) =~ tr!0-9A-Z\0!!c ? '(*FAIL)' : '(*ACCEPT)' }) +/gx; } __DATA__ 1 ABFD-1234 AAA 2 ABFD-178G BBB 3 F2HB-9401 AAA 4 ZDDR-00W5 DDD 5 D7*D-48*6 EEE