Help for this page

Select Code to Download


  1. or download this
    my %countries = (
        India    => 1,
    ...
    if ($countries{$country}){
       print "$country is indeed a country\n";
    }
    
  2. or download this
    use v6; # ensure we run Perl 6
    my $country = 'Foo'
    ...
    if $country eq any(@countries) {
       say "True"
    }
    
  3. or download this
    #!/usr/bin/perl
    use strict;
    ...
        first   => \&mfirst,
        hash    => \&hash,
    });
    
  4. 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%     --
    
  5. 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%     --