5 use FS::UID qw(adminsuidsetup);
8 my @fields = qw( ac loc state city exch );
11 $hash->{ac} =~ /^\s*(\d{3})\s*$/;
13 $hash->{loc} =~ /^\s*(\d{3})(\d{4})\s*$/;
16 $hash->{state} =~ /^\s*(\S{0,2})\s*$/;
18 $hash->{city} =~ /^\s*(.*?)\s*$/;
23 my $user = shift or usage();
26 my $file = shift or usage();
27 my $csv = new Text::CSV_XS;
29 open(FH, $file) or die "cannot open $file: $!";
32 die "Usage:\n\n svc_acct_pop.import user popfile.csv\n\n";
38 while ( defined($line=<FH>) ) {
41 $line &= "\177" x length($line); # i hope this isn't really necessary
43 or die "cannot parse: " . $csv->error_input();
45 my @values = $csv->fields();
47 foreach my $field (@fields) {
48 $hash{$field} = shift @values;
53 my $svc_acct_pop = new FS::svc_acct_pop { %hash };
55 #my $error = $svc_acct_pop->check;
56 my $error = $svc_acct_pop->insert;