=================================================================== RCS file: /cvs/RT/Invoicing/rt_invoices.pl,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- RT/Invoicing/rt_invoices.pl 2015/12/08 02:10:43 1.54 +++ RT/Invoicing/rt_invoices.pl 2020/08/02 18:52:40 1.55 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $AFresh1: rt_invoices.pl,v 1.53 2015/05/07 05:26:08 andrew Exp $ +# $AFresh1: rt_invoices.pl,v 1.54 2015/12/08 02:10:43 andrew Exp $ ######################################################################## # Copyright (c) 2011 Andrew Fresh # @@ -19,7 +19,6 @@ use warnings; use 5.010; -use experimental qw( switch smartmatch ); # Because we don't have a real cert $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; @@ -309,17 +308,23 @@ next unless $cust->{match}; foreach my $m ( @{ $cust->{match} } ) { my $type = $m->{type}; - my $match - = exists $m->{$type} - ? lc( $m->{$type} ) - : qr/\Q$m->{regex}\E/; - my $thing = [ map {lc} $ticket->$type ]; - - if ( !$match ) { - warn "Invalid match!"; - next; + my @things = map {lc} $ticket->$type; + if ( exists $m->{$type} ) { + if ( !$m->{$type} ) { + warn "Invalid match!"; + next; + } + my $match = lc $m->{$type}; + for my $thing (@things) { + return $cust if $thing eq $match; + } } - return $cust if ( $match ~~ $thing ); + else { + my $match = qr/\Q$m->{regex}\E/; + for my $thing (@things) { + return $cust if $thing =~ $match; + } + } } } @@ -610,14 +615,12 @@ my $per = $cust->{per} || 'week'; my $freq = $cust->{frequency} || 1; - my $day_method; - given ($per) { - when ('week') { $per = 'weeks'; $day_method = 'dow' } - when ('month') { $per = 'months'; $day_method = 'day' } - default { die "Unknown per [$per]\n" } - } + my $day_method + = $per eq 'week' ? $day_method = 'dow' + : $per eq 'month' ? $day_method = 'day' + : die "Unknown per [$per]\n"; - return DateTime::Duration->new( $per => $freq ), $day_method; + return DateTime::Duration->new( "${per}s" => $freq ), $day_method; } sub set_dates {