Created
October 17, 2010 19:50
-
-
Save zengargoyle/631196 to your computer and use it in GitHub Desktop.
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/perl -CSDAL | |
# | |
# Usage: PROGNAME big_list.txt small_list.txt > output.txt | |
# -CSDAL for unicode. | |
use strict; | |
use warnings; | |
# should maybe have this | |
use locale; | |
# Read the big/small list file names | |
my $bigfile = shift @ARGV; | |
my $smallfile = shift @ARGV; | |
# Read the small list file, map to UPPER CASE, remove line ending | |
my @small = do { local @ARGV = $smallfile; <> }; | |
@small = map { uc $_ } @small; | |
chomp @small; | |
my %small; | |
$small{$_} = undef for @small; | |
# Read through the big list file | |
@ARGV = $bigfile; | |
while (<>) { | |
chomp; # Get rid of line ending | |
print; # print without any number following and no line ending | |
my $big = uc $_; # make it UPPER CASE | |
#if (grep { $big eq $_ } @small) { # if it is in small list | |
if (exists $small{$big}) { # if it is in small list | |
print " 2"; # add a " 2" to the end. | |
} | |
print "$/"; # print the line ending | |
} |
Author
zengargoyle
commented
Oct 17, 2010
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment