- or download this
my %countries = (
India => 1,
...
if ($countries{$country}){
print "$country is indeed a country\n";
}
- or download this
use v6; # ensure we run Perl 6
my $country = 'Foo'
...
if $country eq any(@countries) {
say "True"
}
- or download this
#!/usr/bin/perl
use strict;
...
first => \&mfirst,
hash => \&hash,
});
- or download this
# perl 5.8.8:
Rate grep first regex hash
...
first 10778/s 26% -- -75% -100%
regex 43115/s 405% 300% -- -99%
hash 3429921/s 40099% 31723% 7855% --
- or download this
sub smartmatch {
die 'smart' unless 'Germany' ~~ @countries;
...
smart 18101/s 139% 98% -- -59% -99%
regex 43840/s 478% 380% 142% -- -99%
hash 3508785/s 46146% 38312% 19285% 7904% --