mirror of
https://github.com/openssl/openssl.git
synced 2024-12-24 17:33:53 +08:00
35c3a562c7
For our own convenience, we need a mechanism to be able to fall back on bundled Perl modules. It's a minimal package that's called like this: use with_fallback qw(Module1 Module2 ...); For each module, it will try to require them from the system installation, and failing that, it will temporarly add external/perl and try to require transfer::{ModuleName}. It requires that each bundled Perl modules is accompanied by a small transfer module (external/perl/transfer/ModuleName.pm in our example) that knows exactly what to load. Reviewed-by: Rich Salz <rsalz@openssl.org>
20 lines
350 B
Perl
20 lines
350 B
Perl
#! /usr/bin/perl
|
|
|
|
package with_fallback;
|
|
|
|
sub import {
|
|
use File::Basename;
|
|
use File::Spec::Functions;
|
|
foreach (@_) {
|
|
eval "require $_";
|
|
if ($@) {
|
|
unshift @INC, catdir(dirname(__FILE__), "..", "external", "perl");
|
|
my $transfer = "transfer::$_";
|
|
eval "require $transfer";
|
|
shift @INC;
|
|
warn $@ if $@;
|
|
}
|
|
}
|
|
}
|
|
1;
|