Skip to content

Instantly share code, notes, and snippets.

@note103
Created February 11, 2015 16:47
Show Gist options
  • Save note103/4fb227224dec50fdbba2 to your computer and use it in GitHub Desktop.
Save note103/4fb227224dec50fdbba2 to your computer and use it in GitHub Desktop.
overlap.pl
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use feature 'say';
my $switch = 'o';
#my $switch = 'u';
my %count;
for (<DATA>) {
$count{$_}++;
}
if ($switch eq 'o') {
my @overlap = grep {$count{$_} >= 2} keys %count;
say "overlap:";
say @overlap;
} elsif ($switch eq 'u') {
my @unique = grep {$count{$_} == 1} keys %count;
say "unique:";
say @unique;
}
__DATA__
orange
apple
lemon
orange
lemon
orange
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment