Re: PAR and BEGINs

Juan José 'Peco' San Martín <[email protected]>
Newsgroups gmane.comp.lang.perl.par
Message-ID <CAPGFf2GLTN3=YMqVvjcNw91ANe32UZa7WCLe=wLAxyEyk3W3dg@mail.gmail.com>
Hello Shawn,

You were absolutely right
Thank you very much for this light.

I'll write a bug (note) into the Module::ScanDeps to record this.

Regards,
Peco

2016-09-16 4:20 GMT+02:00 Shawn Laffan <[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
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.