#!/usr/bin/env perl use warnings; use strict; my %countries; my %seen; my @dup; my @countries; my $holiday; my @cntry_of_issue = ('US','CA'); while () { chomp; next if /^\s*$/ || /^\#/; my $aref = [split /,/, $_]; push( @{$countries{$aref->[2]}}, $aref->[5]); } sub strip_US_CA_dup_hols { for (@cntry_of_issue) { foreach $holiday (@{$countries{$_}}) { $seen{$holiday}++; } }#end of for while ( my ($key, $value) = each %seen ) { push @dup,$key if $value > 1; } for (@cntry_of_issue) { delete $@{$countries{$_}} if grep /@{$countries{$_}}/, @dup; } }#end of function &strip_US_CA_dup_hols; __DATA__ 808,XNYS,US,New York Stock Exchange,2012,20120102,Mon,New Year's Day OBS,T 808,XNYS,US,New York Stock Exchange,2012,20120116,Mon,Martin Luther King Jr. Day,T 808,XNYS,US,New York Stock Exchange,2012,20120220,Mon,Presidents' Day,T 808,XNYS,US,New York Stock Exchange,2012,20120406,Fri,Good Friday,T 808,XNYS,US,New York Stock Exchange,2012,20120528,Mon,Memorial Day,T 808,XNYS,US,New York Stock Exchange,2012,20120704,Wed,Independence Day,T 808,XNYS,US,New York Stock Exchange,2012,20120903,Mon,Labor Day,T 808,XNYS,US,New York Stock Exchange,2012,20121122,Thu,Thanksgiving,T 808,XNYS,US,New York Stock Exchange,2012,20121225,Tue,Christmas,T 665,XTSE,CA,Toronto Stock Exchange,2012,20120102,Mon,New Year's Day OBS,T 665,XTSE,CA,Toronto Stock Exchange,2012,20120220,Mon,Family Day,T 665,XTSE,CA,Toronto Stock Exchange,2012,20120406,Fri,Good Friday,T 665,XTSE,CA,Toronto Stock Exchange,2012,20120521,Mon,Victoria/Patriots' Day,T 665,XTSE,CA,Toronto Stock Exchange,2012,20120702,Mon,Canada Day OBS,T 665,XTSE,CA,Toronto Stock Exchange,2012,20120806,Mon,Civic Holiday,T 665,XTSE,CA,Toronto Stock Exchange,2012,20120903,Mon,Labour Day,T 665,XTSE,CA,Toronto Stock Exchange,2012,20121008,Mon,Thanksgiving,T 665,XTSE,CA,Toronto Stock Exchange,2012,20121225,Tue,Christmas,T 665,XTSE,CA,Toronto Stock Exchange,2012,20121226,Wed,Boxing Day,T