Skip to content

Instantly share code, notes, and snippets.

@warewolf
Created November 29, 2012 20:08
Show Gist options
  • Select an option

  • Save warewolf/4171569 to your computer and use it in GitHub Desktop.

Select an option

Save warewolf/4171569 to your computer and use it in GitHub Desktop.
dedupe with a haSh in perl
#!/usr/bin/perl
use strict;
use warnings;
my @values = qw( a b c d a b c d a b c d);
my %dedupe_hash;
foreach my $value (@values) {
$dedupe_hash{$value}++;
}
foreach my $key (keys %dedupe_hash) {
my $value = $dedupe_hash{$value};
print "key $key has value $value\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment