Re: PAR and BEGINs
Shawn Laffan <[email protected]>
| Newsgroups | gmane.comp.lang.perl.par |
|---|---|
| Message-ID | <[email protected]> |
Hello Peco,
The issue is probably because Module::ScanDeps does not parse that
construct and so it is not packed.
A couple of options are:
1. Put the explicit require line in your calling script (or other
library under your control). There should be not need add it to @ISA as
Net::DNS::Resolver will (should) find the packed version and handle it
as needed.
2. Use the -M flag when packing your script using pp.
https://metacpan.org/pod/pp
To pack only one variant:
pp -M Net::DNS::Resolver::UNIX yourscript.pl
Or if you just want to use one command across platforms and are happy to
pack all variants, then you can use this. (It needs Par::Packer 1.031
or higher).
pp -M Net::DNS::Resolver:: yourscript.pl
See the documentation at https://metacpan.org/pod/pp
Regards,
Shawn.
On 16/09/2016 0:20, Juan José 'Peco' San Martín wrote:
> Hello all!
>
> I have a strange behaviour, any idea or help is welcome.
>
> I've developed a program in Linux that by dependencies needs
> /usr/lib/perl5/Net/DNS/Resolver.pm
>
> The last release of Resolver.pm starts with a BEGIN block like follows:
>
> /use vars qw(@ISA);
> BEGIN {
> for ( $^O, 'UNIX' ) {
> my $class = join '::', __PACKAGE__, $_;
> return @ISA = ($class) if eval "require $class;";
> }
> die 'failed to load platform specific resolver component';
> }
> /
> The program works, so I created the executable to make an easier
> deployment...
> but I am surprised to see that it fails with the message: /failed to
> load platform specific resolver component/
>
> The workaround is replace the BEGIN by something platform dependent:
>
> require Net::DNS::Resolver::UNIX;
> @ISA = qw(Net::DNS::Resolver::UNIX);
>
> Any idea?
>
> Cheers,
> Peco