The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Code::Embeddable - Collection of routines that can be embedded e.g. using Dist::Zilla plugin

VERSION

This document describes version 0.05 of Code::Embeddable (from Perl distribution Code-Embeddable), released on 2015-06-18.

SYNOPSIS

In dist.ini:

 [InsertBlock::FromModule]

In lib/Your/Module.pm (that wants to embed one or more routines):

 # INSERT_BLOCK: Code::Embeddable import
 # INSERT_BLOCK: Code::Embeddable another_func

DESCRIPTION

This module is a collection of functions that can be embedded into another file's source code, e.g. using Dist::Zilla::Plugin::InsertBlock::FromModule (if you're using Dist::Zilla to build your dists).

The functions put here are usually routines that are small, independent, and stable (doesn't change that much). Instead of require-ing a module that contains these routines, a client code can opt to embed them directly in its file instead. The advantage is less dependencies (no other module to depend on) and slightly smaller startup overhead. Compared to manual "copy-pasting" of code, embedding using Dist::Zilla::Plugin::InsertBlock::FromModule is more maintainable.

FUNCTIONS

import

A lightweight Exporter-style exporter. Supports @EXPORT and @EXPORT_OK. No support for tags.

pick(@list) => $item

Pick a random item from a list. Will return undef if @ary is empty.

pick_n($n, @list) => @items

Pick $n items from a list.

shuffle(@list) => @shuffled

Just like List::Util's shuffle, except implemented in pure Perl and you don't have to load the module.

uniq(@list) => @unique

Just like List::MoreUtils's uniq, except implemented in pure Perl and you don't have to load the module.

ROUTINES

These embeddable pieces of code are not function declaration:

SEE ALSO

Dist::Zilla::Plugin::InsertBlock::FromModule

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Code-Embeddable.

SOURCE

Source repository is at https://github.com/perlancar/perl-Code-Embeddable.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Code-Embeddable

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 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.