in reply to Re: Bundling a module with a distribution
in thread Bundling a module with a distribution (cross-platform)

Take a look at simonm's Clone::Any and Clone::PP. Pure perl, no XS.

qq

  • Comment on Re^2: Bundling a module with a distribution

Replies are listed 'Best First'.
Re^3: Bundling a module with a distribution
by anjoschu (Sexton) on Jan 02, 2005 at 11:28 UTC

    Devel::UseAnyFunc, which Clone::Any depends on, uses eval { require $pm } to check for available modules. It does not check whether the call of the clone function succeeds.

    In this case with an unsupported architecture, the whole thing fails when clone is first called. That's why, unfortunately, Clone::Any does not work here. simonm pointed me to this in an email.

    Probably Devel::UseAnyFunc can be expanded by a eval call of the function in question (here clone). I'll mention this to simonm. On the other hand, Devel::UseAnyFunc would need to know how the function wants to be called. Oh well...

    Clone::PP looks like the solution (thanks qq). Albeit slower than Clone (and Storable for that matter) and having some limitations, it probably will work well for my purposes.

    Storable's dclone would also work. It is part of the core distribution of perl. Maybe I should use that. On the other hand, this may change with Perl 5.10.

    What, me indecisive? ;-)

      Devel::UseAnyFunc, which Clone::Any depends on, uses eval { require $pm } to check for available modules. It does not check whether the call of the clone function succeeds.

      Yup; I basically assumed that if the module is installed, it will work.

      The code for Devel::UseAnyFunc is fairly simple, so you could build your own version of it that also did this extra check before deciding which function to import.

        The code snippet you sent me does exactly what I wanted. Assuming your permission, I'm posting it here for all to see.

        if ( eval { require Clone; Clone::clone( "testdata" ); 1 } ) { eval "use Clone qw( clone );" } else { eval "use Clone::PP qw( clone );" }

        Thanks to all and particularly to simonm for their help! This has indeed been a warm welcome to perlmonks.