use Perl6::Junction qw/all/; my $sPhoneCapabilityCode = "00000490"; my $s3905CapabilityCode ="00000290"; chomp( my $sUnpackedCDPcap = ); if ( $sUnpackedCDPcap ne all($sPhoneCapabilityCode,$s3905CapabilityCode) ) { print "Bingo!\n"; } #### Rate junct regex raw hash junct 104/s -- -79% -87% -95% regex 504/s 386% -- -38% -74% raw 806/s 678% 60% -- -58% hash 1932/s 1763% 284% 140% -- #### #!/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; }, } );