} elsif ( $format eq 'cch-zip' || $format eq 'cch-update-zip' ) {
@fields = qw( zip city county state postalcity countyfips countydef default geocode cityflag unique );
- push @fields, 'actionflag' if $format eq 'cch-update';
+ push @fields, 'actionflag' if $format eq 'cch-update-zip';
$imported++ if $format eq 'cch-update'; #empty file ok
UNLINK => 0, #meh
) or die "can't open temp file: $!\n";
+ my $insert_pattern = ($format eq 'cch-update') ? qr/"I"\s*$/ : qr/I\s*$/;
+ my $delete_pattern = ($format eq 'cch-update') ? qr/"D"\s*$/ : qr/D\s*$/;
while(<$fh>) {
my $handle = '';
- $handle = $ifh if $_ =~ /"I"\s*$/;
- $handle = $dfh if $_ =~ /"D"\s*$/;
+ $handle = $ifh if $_ =~ /$insert_pattern/;
+ $handle = $dfh if $_ =~ /$delete_pattern/;
unless ($handle) {
$error = "bad input line: $_" unless $handle;
last;