Help for this page

Select Code to Download


  1. or download this
    my %capitals = (France => "Paris",
                    Scotland => "Edinburgh",
                    );
    # find the capital "of" Scotland
    print $capitals{"Scotland"}, "\n";
    
  2. or download this
    # we have a pre-prepared list of prime numbers
    my @primeslist  =  qw(2 3 5 7 11 13 17 19 23 29);
    ...
    # using the exists() function to (quickly) check if a key exists
    print "$_ is prime\n" for grep exists $primes{$_}, 1 .. 30;