4 use vars qw($opt_g $opt_f);
7 use FS::UID qw(adminsuidsetup);
9 use FS::tax_rate_location;
13 my $user = shift or die &usage;
14 my $dbh = adminsuidsetup $user;
16 my ($format) = $opt_f =~ /^([-\w]+)$/;
19 'GEOCODE', $opt_g, \&FS::tax_rate_location::batch_import,
22 my $oldAutoCommit = $FS::UID::AutoCommit;
23 local $FS::UID::AutoCommit = 0;
28 my ($name, $file, $method) = splice(@list, 0, 3);
32 $file =~ /^([\s\d\w.]+)$/ or die "Illegal filename: $file\n";
35 open $fh, '<', $file or die "can't open $name file: $!\n";
36 $error ||= &{$method}( { filehandle => $fh, 'format' => $format, } );
38 die "error while processing $file: $error" if $error;
43 $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
45 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
48 sub usage { die "Usage:\ntax_rates_location.import -f FORMAT -g GEOCODEFILE user\n\n"; }