@@ -, +, @@ --- C4/Biblio.pm | 11 +++++------ misc/link_bibs_to_authorities.pl | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -28,6 +28,7 @@ use MARC::Record; use MARC::File::USMARC; use MARC::File::XML; use POSIX qw(strftime); +use Module::Load::Conditional qw(can_load); use C4::Koha; use C4::Dates qw/format_date/; @@ -491,13 +492,11 @@ sub BiblioAutoLink { my $linker_module = "C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' ); - eval { eval {require $linker_module}; }; - if ($@) { + unless ( can_load( modules => { $linker_module => undef } ) ) { $linker_module = 'C4::Linker::Default'; - eval {require $linker_module}; - } - if ($@) { - return 0, 0; + unless ( can_load( modules => { $linker_module => undef } ) ) { + return 0, 0; + } } my $linker = $linker_module->new( --- a/misc/link_bibs_to_authorities.pl +++ a/misc/link_bibs_to_authorities.pl @@ -18,6 +18,7 @@ use Pod::Usage; use Data::Dumper; use Time::HiRes qw/time/; use POSIX qw/strftime ceil/; +use Module::Load::Conditional qw(can_load); sub usage { pod2usage( -verbose => 2 ); @@ -53,13 +54,11 @@ if ( not $result or $want_help ) { my $linker_module = "C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' ); -eval { eval "require $linker_module"; }; -if ($@) { +unless ( can_load( modules => { $linker_module => undef } ) ) { $linker_module = 'C4::Linker::Default'; - eval "require $linker_module"; -} -if ($@) { - die "Unable to load linker module. Aborting."; + unless ( can_load( modules => { $linker_module => undef } ) ) { + die "Unable to load linker module. Aborting."; + } } my $linker = $linker_module->new( --