#!/usr/bin/env perl use warnings; use strict; use Benchmark qw/cmpthese/; my @testdata = map { sprintf "%08d", $_*97 } 0..9999; my @m = qw/ 00000490 00000290 00000100 00000123 00000970 /; use Perl6::Junction qw/all/; # prep for hash my %h = map {$_=>1} @m; # prep for regex my ($re) = map {qr/\A(?:$_)\z/} join '|', map {quotemeta} sort { length $b <=> length $a } @m; cmpthese(-1, { raw => sub { my $found; for my $x (@testdata) { if ($x ne $m[0] && $x ne $m[1] && $x ne $m[2] && $x ne $m[3] && $x ne $m[4]) { $found++ } } die "raw: $found" unless $found==9999; }, hash => sub { my $found; for my $x (@testdata) { if ( !exists $h{$x} ) { $found++ } } die "hash: $found" unless $found==9999; }, regex => sub { my $found; for my $x (@testdata) { if ( $x!~$re ) { $found++ } } die "regex: $found" unless $found==9999; }, junct => sub { my $found; for my $x (@testdata) { if ( $x ne all(@m) ) { $found++ } } die "junct: $found" unless $found==9999; }, } );