Koha/Koha/MoreUtils.pm
Jonathan Druart bdf85f5e39 Bug 19069: Fix 'does not match' behaviour in MARC modification template
The "does not match" condition does not behave as expected.
We want it to process the action if the subfield exists and that the
value does not match a given pattern.

Test plan:
Be creative and write different template actions using the "does not
match" condition.
Using the "Batch record modification" and the "Show MARC" popup, confirm
that the processed record is the one you are expecting.

Signed-off-by: Jon Knight <J.P.Knight@lboro.ac.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-10-27 14:09:01 -03:00

15 lines
291 B
Perl

package Koha::MoreUtils;
use Modern::Perl;
# From List::MoreUtils v4.0
sub singleton (@)
{
my %seen = ();
my $k;
my $seen_undef;
grep { 1 == ( defined $_ ? $seen{ $k = $_ } : $seen_undef ) }
grep { defined $_ ? not $seen{ $k = $_ }++ : not $seen_undef++ } @_;
}
1;