Clone::Choose

Latest version: 0.010 registry icon
Maintenance score
0
Safety score
0
Popularity score
3
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
0.010 0 0 0 0 0
0.009 0 0 0 0 0
0.008 0 0 0 0 0
0.007 0 0 0 0 0
0.006 0 0 0 0 0
0.004 0 0 0 0 0
0.002 0 0 0 0 0

Stability
Latest release:

0.010 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

GPL-1.0-or-later   -   GNU General Public License v1.0 or later

Not a wildcard

Not proprietary

OSI Compliant


Artistic-1.0   -   Artistic License 1.0

Not a wildcard

Not proprietary

OSI Compliant



NAME

Clone::Choose - Choose appropriate clone utility

SYNOPSIS

use Clone::Choose;

my $data = {
    value => 42,
    href  => {
        set   => [ 'foo', 'bar' ],
        value => 'baz',
    },
};

my $cloned_data = clone $data;

# it's also possible to use Clone::Choose and pass a clone preference
use Clone::Choose qw(:Storable);

DESCRIPTION

Clone::Choose checks several different modules which provides a clone() function and selects an appropriate one. The default preference is

Clone
Storable
Clone::PP

This list might evolve in future. Please see "EXPORTS" how to pick a particular one.

EXPORTS

Clone::Choose exports clone() by default.

One can explicitly import clone by using

use Clone::Choose qw(clone);

or pick a particular clone implementation

use Clone::Choose qw(:Storable clone);

The exported implementation is resolved dynamically, which means that any using module can either rely on the default backend preference or choose a particular one.

It is also possible to select a particular clone backend by setting the environment variable CLONE_CHOOSE_PREFERRED_BACKEND to your preferred backend.

This also means, an already chosen import can't be modified like

use Clone::Choose qw(clone :Storable);

When one seriously needs different clone implementations, our recommended way to use them would be:

use Clone::Choose (); # do not import
my ($xs_clone, $st_clone);
{ local @Clone::Choose::BACKENDS = (Clone => "clone"); $xs_clone = Clone::Choose->can("clone"); }
{ local @Clone::Choose::BACKENDS = (Storable => "dclone"); $st_clone = Clone::Choose->can("clone"); }

Don't misinterpret recommended - modifying @Clone::Choose::BACKENDS has a lot of pitfalls and is unreliable beside such small examples. Do not hesitate open a request with an appropriate proposal for choosing implementations dynamically.

The use of @Clone::Choose::BACKENDS is discouraged and will be deprecated as soon as anyone provides a better idea.

PACKAGE METHODS

backend

backend tells the caller about the dynamic chosen backend:

use Clone::Choose;
say Clone::Choose->backend; # Clone

This method currently exists for debug purposes only.

get_backends

get_backends returns a list of the currently supported backends.

AUTHOR

Jens Rehsack <rehsack at cpan dot org>
Stefan Hermes <hermes at cpan dot org>

BUGS

Please report any bugs or feature requests to bug-Clone-Choose at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Clone-Choose. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Clone::Choose

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2017 Jens Rehsack
Copyright 2017 Stefan Hermes

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

SEE ALSO

Clone, Clone::PP, Storable