-my $svc_something = shift or die &usage;
-my $svc_x;
-if ( $svc_something =~ /^(\d+)$/ ) {
- my $cust_svc = qsearchs('cust_svc', { svcnum=>$1 } )
- or die "svcnum $svc_something not found\n";
- $svc_x = $cust_svc->svc_x;
-} else {
- $svc_x = qsearchs('svc_acct', { username=>$svc_something } )
- or die "username $svc_something not found\n";
+getopts('s:u:p:e:');
+
+my @svc_x = ();
+if ( $opt_s ) {
+ my $cust_svc = qsearchs('cust_svc', { svcnum=>$opt_s } )
+ or die "svcnum $opt_s not found\n";
+ push @svc_x, $cust_svc->svc_x;
+} elsif ( $opt_u ) {
+ my $svc_x = qsearchs('svc_acct', { username=>$opt_u } )
+ or die "username $opt_u not found\n";
+ push @svc_x, $svc_x;
+} elsif ( $opt_p ) {
+ push @svc_x, map { $_->svc_x } qsearch('cust_svc', { svcpart=>$opt_p } );
+ die "no services with svcpart $opt_p found\n" unless @svc_x;