From cadce65fc55c0e9d16a7b8683cd8e0290fc6efde Mon Sep 17 00:00:00 2001 From: blake Date: Wed, 30 Oct 2024 09:50:18 -0500 Subject: [PATCH] Cuts down on the perl warnings Cuts down on the perl warnings when an undefined value makes it's way into the field sub. Tested on 120k bibs for a migration. Tested before/after and found that the result was identical but with the patch, much less noise! --- marc-record/lib/MARC/Record.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/marc-record/lib/MARC/Record.pm b/marc-record/lib/MARC/Record.pm index be0fe8e..d756cd5 100644 --- a/marc-record/lib/MARC/Record.pm +++ b/marc-record/lib/MARC/Record.pm @@ -199,16 +199,16 @@ sub field { my @list = (); for my $tag ( @specs ) { - my $regex = $field_regex{ $tag }; + my $regex = (defined $tag) ? $field_regex{ $tag } : undef; # Compile & stash it if necessary - if ( not defined $regex ) { + if ( not defined $regex and defined $tag ) { $regex = qr/^$tag$/; $field_regex{ $tag } = $regex; } # not defined for my $maybe ( $self->fields ) { - if ( $maybe->tag =~ $regex ) { + if ( defined $regex and $maybe->tag =~ $regex ) { return $maybe unless wantarray; push( @list, $maybe );