Clone::Choose(3)
π Clone::Choose(3) β the perl-y "pick a clone backend" situation π
okay so you're reading the manual for Clone::Choose, a User Contributed Perl Documentation page (yes bestie, we're in the Clone::Choose(3) section of the man pages, stay with me π«Ά).
β¨ NAME β¨
Clone::Choose β literally just "choose appropriate clone utility". That's the whole vibe. It picks the right clone tool for you so you don't have to π
πΈ SYNOPSIS πΈ
here's the whole thing in action, no cap:
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);
see that? clone $data and boom, you got a copy. and yes, you can also use Clone::Choose with a clone preference if you're feeling picky π
π¦ DESCRIPTION π¦
so Clone::Choose goes around checking several different modules that each provide a clone() function, and then it selects an appropriate one for you. it's giving "personal assistant but for Perl modules" β¨
the default preference order is, in this exact order:
Clone
Storable
Clone::PP
now β this list might evolve in future, so don't get too attached, okay? if you wanna pick a particular one yourself, the "EXPORTS" section has you covered π
π EXPORTS π
Clone::Choose exports clone() by default. free function, no questions asked π«Ά
you can also explicitly import clone by using:
use Clone::Choose qw(clone);
or you can pick a particular clone implementation, like so:
use Clone::Choose qw(:Storable clone);
the exported implementation is resolved dynamically, which is the fancy way of saying: any module that uses this can either rely on the default backend preference, or choose a particular one. flexible. iconic. main character energy π§
you can also select a particular clone backend by setting the environment variable CLONE_CHOOSE_PREFERRED_BACKEND to whatever your preferred backend is. yup, that's the whole name, i know, it's long, drink some water π
this also means an already chosen import can't be modified afterwards, like:
use Clone::Choose qw(clone :Storable);
nope. not allowed. the vibes are already locked in π
when you seriously need different clone implementations at the same time, the 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"); }
π¨ okay bestie, warning time: don't misinterpret "recommended" here. modifying @Clone::Choose::BACKENDS has a lot of pitfalls and it is unreliable beside such small examples. like, fr fr. if you've got a better way, do not hesitate to open a request with an appropriate proposal for choosing implementations dynamically β they want your ideas π
and straight up: the use of @Clone::Choose::BACKENDS is discouraged, and it will be deprecated as soon as anyone provides a better idea. so like... someone please provide a better idea? π
π PACKAGE METHODS π
π backend
backend tells the caller about the dynamically chosen backend. look:
use Clone::Choose;
say Clone::Choose->backend; # Clone
this method currently exists for debug purposes only. that's it. that's the whole method. tiny but mighty π
β get_backends
get_backends returns a list of the currently supported backends. simple as. π
π§ AUTHOR π§
Jens Rehsack <rehsack at cpan dot org>
Stefan Hermes <hermes at cpan dot org>
shoutout to the authors, absolute legends, we stan π
π 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" β meaning the author β will be notified, and then you'll automatically be notified of progress on your bug as changes get made. it's a whole notification circle of trust π
πΈ SUPPORT πΈ
you can find documentation for this module with the perldoc command:
perldoc Clone::Choose
you can also look for information at:
- RT: CPAN's request tracker β <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Clone-Choose>
- AnnoCPAN: Annotated CPAN documentation β <http://annocpan.org/dist/Clone-Choose>
- CPAN Ratings β <http://cpanratings.perl.org/d/Clone-Choose>
- Search CPAN β <http://search.cpan.org/dist/Clone-Choose/>
like four whole places to look. the internet is vast and full of Clone::Choose lore π
π 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. pick your fighter βοΈ
see <http://dev.perl.org/licenses/> for more information. go read the licenses, it's good for you π«Ά
π SEE ALSO π
Clone, Clone::PP, Storable β the whole squad, go say hi β¨
and that's the page, bestie π β brought to you by perl v5.42.0, dated 2018-10-09, signing off from the Clone::Choose(3) corner of the man page universe. slay, and happy cloning ππ
π¦
π¦ where this page comes from
- opensuse-leap 16.0: perl-Clone-Choose 0.010-bp160.1.10 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms