Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Bundling a module with a distribution

by qq (Hermit)
on Dec 30, 2004 at 00:56 UTC ( [id://418146]=note: print w/replies, xml ) Need Help??


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

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://418146]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-03-19 10:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found