+ my ($custnum,$cust_main);
+ if ($opt_E) {
+ # don't really need to validate input here, search will quote safely
+ unless ( /^\s*(.*)\s*$/ ) {
+ warn "unparsable line: $_";
+ next;
+ }
+ my @cust_main = FS::cust_main::Search::email_search( 'email' => $1 );
+ if (@cust_main > 1) {
+ warn "muliple matching customers for address, skipping: $_";
+ next;
+ } elsif (@cust_main < 1) {
+ warn "could not find matching customer for address, skipping: $_";
+ next;
+ }
+ $cust_main = $cust_main[0];
+ $custnum = $cust_main->custnum;
+ } else {
+ unless ( /^\s*(\d+)\s*$/ ) {
+ warn "unparsable line: $_";
+ next;
+ }
+ my $custnum = $1;
+ $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+ unless ( $cust_main ) {
+ warn "unknown custnum $custnum\n";
+ next;
+ }