Created
March 4, 2011 04:09
-
-
Save willwillis/854160 to your computer and use it in GitHub Desktop.
splits a ward directory from lds.org based on last names
This file contains hidden or 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
#!/opt/local/bin/perl | |
use strict; | |
my $print_to_files = 1; | |
my $full_roster = '/Users/will/Downloads/221899-2011-03-03.csv'; | |
die "$full_roster does not exist!" unless -e $full_roster; | |
my @parts = qw[ A-D E-H J-P R-Z ]; | |
open (my $fh, "<", $full_roster) || die $!; | |
my @lines = <$fh>; | |
shift @lines; | |
foreach my $group (@parts) { | |
print "======== $group =======\n"; | |
open (my $out, ">", "$group.csv") || die $!; | |
foreach my $line (@lines) { | |
chomp $line; | |
my $re = qr/^\"[$group]/; | |
print $out "$line \n" if $line =~ $re; | |
} | |
close $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment