Skip to content

Instantly share code, notes, and snippets.

@Mossuru777
Created June 18, 2015 12:23
Show Gist options
  • Save Mossuru777/87c122353d2f3d09fe69 to your computer and use it in GitHub Desktop.
Save Mossuru777/87c122353d2f3d09fe69 to your computer and use it in GitHub Desktop.
Number(String) Compare
use Benchmark qw/cmpthese/;
my @input = ("1", "0");
cmpthese(0, {
'String' => sub { foreach (@data) { $_ eq "0" || $_ eq "1" } },
'Number' => sub { foreach (@data) { $_ == 0 || $_ == 1 } },
'Regex' => sub { foreach (@data) { $_ =~ /^[01]$/ } }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment