Help for this page

Select Code to Download


  1. or download this
    my %hash          = ( a => 1, b => 2, c => 3 );
    my %inverted_hash = reverse %hash;
    
  2. or download this
    use Data::Dumper;
    print Dumper(\(%hash, %inverted_hash));
    ...
    #           '3' => 'c',
    #           '2' => 'b'
    #         };
    
  3. or download this
    %hash          = ( a => 1, b => 2, c => 2 );
    %inverted_hash = reverse %hash;
    ...
    #           '1' => 'a',
    #           '2' => 'c'
    #         };
    
  4. or download this
    print "keys were lost during inversion\n"
        if keys %inverted_hash < keys %hash;