Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

The Uniqueness of hashes.

by injunjoel (Priest)
on Sep 25, 2005 at 02:37 UTC ( #494836=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl, v5.8.0 built for MSWin32-x86-multi-thread
    
  2. or download this
    #!/usr/bin/perl
     
    ...
        print "\n";
    }
    
  3. or download this
    
    my @array1 = (1 .. 20);
    ...
    '21','22','23','24','25','26','27','28','29','30',
    '31','32','33','34','35','36','37','38','39','40']
    
  4. or download this
    
    my %unique_sets;
    ...
      '40' => [40]
    }
    
  5. or download this
    
    my %unique_counts = do{ 
    ...
      '40' => 1
    }
    
  6. or download this
    
    my %duplicates = do{
    ...
      '29' => 2,
      '30' => 2
    }
    
  7. or download this
    
    my %non_duplicates = do{
    ...
      '40' => 1
    }
    
  8. or download this
    
    my %unique_descriptive = do {
    ...
    }
    
    
  9. or download this
    
    my %max = do{
    ...
      'count' => 3,
      'values' => [20,20,20]
    }
    
  10. or download this
    
    my %min = do{
    ...
      'count' => 1,
      'values' => [40]
    }
    
  11. or download this
        shift @{[ 
            map{$_->[2]} 
            sort{$a->[0] <=> $b->[0] || $a->[1] <=> $b->[1]} 
            map{[$_{$_}->{count}, $_, $_{$_}]} keys %_ 
            ]}
    
  12. or download this
    ... = do {
            local %_ = %unique_descriptive;
    ...
                sort{ $_{$a}->{count} <=> $_{$b}->{count} || $b <=> $a} ke
    +ys %_ 
            ]}}};
    };
    
  13. or download this
    #!/usr/bin/perl -w
    use strict;
    ...
    print OUTPUT, $d{$_}."\n" for(sort keys %d);
    close OUTPUT;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://494836]
Approved by planetscape
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2017-06-29 00:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (653 votes). Check out past polls.