Skip to content

Instantly share code, notes, and snippets.

@willwillis
Created March 4, 2011 04:09
Show Gist options
  • Save willwillis/854160 to your computer and use it in GitHub Desktop.
Save willwillis/854160 to your computer and use it in GitHub Desktop.
splits a ward directory from lds.org based on last names
#!/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