Created
February 11, 2015 16:47
-
-
Save note103/4fb227224dec50fdbba2 to your computer and use it in GitHub Desktop.
overlap.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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