Functi...reOrPP(3pm)

πŸ“¦
version 0.090 Β· 2 versions
  • 0.090 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.090 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Function::Fallback::CoreOrPP πŸ’–

okay bestie, gather round, because this one is Function::Fallback::CoreOrPP(3pm) β€” a lil Perl module that's literally the "if you don't got the fancy stuff, I got you" friend of the CPAN world. 🫢


✨ VERSION ✨

This doc describes version 0.090 of Function::Fallback::CoreOrPP (it comes from the Perl distribution Function-Fallback-CoreOrPP), and it dropped on 2020-02-03. πŸŽ€


✨ SYNOPSIS ✨

use Function::Fallback::CoreOrPP qw(clone unbless uniq);

my $clone = clone({blah=>1});
my $unblessed = unbless($blessed_ref);
my @uniq  = uniq(1, 3, 2, 1, 4);  # -> (1, 3, 2, 4)

✨ DESCRIPTION ✨

So here's the vibe: this module hands you functions that prefer the non-core XS modules β€” because speed, reliability, features, all that good good ✨ β€” but if that non-core XS module isn't installed, it gracefully falls back to versions built on core XS or plain pure-Perl modules. No drama, no crash, it just adapts. πŸ’…

And why do you care? Because this is the move when you wanna bootstrap your Perl app as a portable, dependency-free Perl script. In a vanilla Perl installation (aka the one that only has core modules), you can use App::FatPacker to pack non-core pure-Perl dependencies straight into your script. Iconic behavior, honestly. πŸ”₯


✨ FUNCTIONS ✨

🌸 clone($data) => $cloned

It tries to use Data::Clone's "clone" first, and if that's not around, it falls back to Clone::PP's "clone". Either way, you get a clone. Slay. πŸ’–

🌸 clone_list(@data) => @data

Just a lil shortcut, and it's exactly this:

return map {clone($_)} @data

🌸 unbless($ref) => $unblessed_ref

It tries to use Acme::Damn's "damn" to unbless a reference, but falls back to shallow copying.

NOTE: "damn()" MODIFIES the original reference. (XXX β€” in the future an option to clone the reference first will be provided.) Meanwhile, the shallow copying route returns a shallow copy. 😭
NOTE: The shallow copy method currently only handles blessed {scalar,array,hash}ref, because honestly those are the most common ones. 🫢

🌸 uniq(@ary) => @uniq_ary

It tries to use List::MoreUtils's "uniq", but falls back to a slower, pure-Perl implementation when it has to. Not the fastest, but it shows up. πŸ’€


✨ HOMEPAGE ✨

Come visit the project's homepage, it's cute, I promise: <https://metacpan.org/release/Function-Fallback-CoreOrPP> πŸ¦‹


✨ SOURCE ✨

The source repo lives right here: <https://github.com/perlancar/perl-Function-Fallback-CoreOrPP> 🌈


✨ BUGS ✨

Please report any bugs or feature requests on the bugtracker website: <https://rt.cpan.org/Public/Dist/Display.html?Name=Function-Fallback-CoreOrPP> πŸ™ˆ

And when you submit a bug or a request, pleaaase include a test-file or a patch to an existing test-file that shows off the bug or the feature you want. That's the whole assignment, bestie. πŸ“


✨ SEE ALSO ✨

Clone::Any can also use multiple backends, no cap. The author used to avoid it because Storable's "dclone" (which is the backend it uses) didn't support Regexp objects out of the box until version 3.08. Plus, it has to use deparse to handle coderefs. So, y'know. ✨


✨ AUTHOR ✨

perlancar <perlancar@cpan.org> πŸ‘‘


This software is copyright (c) 2020, 2017, 2016, 2014 by perlancar@cpan.org. πŸ’œ

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay that's the whole page, you ate it, periodt πŸŽ€ this was perl v5.36.0, dated 2022-11-19, and yes the manual name got a lil chopped in the header as Functi...reOrPP(3pm) β€” that's just the man page being extra, not you. bye bestie, go clone something πŸŒΈπŸ’–

πŸ“¦ where this page comes from