Module::FeaturesUtil::Get - Get a feature from a module (following Module::Features specification)
This document describes version 0.005 of Module::FeaturesUtil::Get (from Perl distribution Module-FeaturesUtil-Get), released on 2021-07-31.
use Module::FeaturesUtil::Get qw( get_features_decl get_feature_val module_declares_feature ); # Get features declaration: my $features_decl = get_features_decl('Text::Table::Tiny'); # Get value of a feature: if (!get_feature_val('Text::Table::Tiny', 'TextTable', 'align_cell_containing_color_codes')) { # strip color codes first for ($str1, $str2) { s/\e\[[0-9;]+m/sg } } push @rows, [$str1, $str2]; # Check whether a module declares a feature: if (module_declares_feature('Text::Table::Tiny', 'TextTable', 'speed')) { ... }
See "GLOSSARY" in Module::Features for terminology.
Usage:
my $feature_set_spec = get_feature_set_spec($feature_set_name);
Feature set specification will be retrieved from the Module::Features::$feature_set_name module. The module will NOT be loaded by this routine; you will need to load the module yourself.
Module::Features::$feature_set_name
This module will also NOT check the validity of feature set specification.
my $features_decl = get_features_decl($module_name);
Features declaration is first looked up from proxy module's %FEATURES package variable, then from the module's %FEATURES. Proxy module is $module_name::_ModuleFeatures. You have to load the modules yourself; this routine will not load the modules for you.
%FEATURES
$module_name
This routine will also NOT check the validity of features declaration.
my $val = get_feature_val($module_name, $feature_set_name, $feature_name);
Example:
if (!get_feature_val('Text::Table::Tiny', 'TextTable', 'align_cell_containing_color_codes')) { # strip color codes first for ($str1, $str2) { s/\e\[[0-9;]+m/sg } } push @rows, [$str1, $str2];
Get the value of a feature from a module's features declaration.
Features declaration is retrieved using "get_features_decl".
This routine will also NOT check the validity of feature value against the specification's schema.
my $bool = module_declares_feature($module_name, $feature_set_name, $feature_name);
Check whether module declares a feature.
This routine will also NOT check the feature set specification.
Please visit the project's homepage at https://metacpan.org/release/Module-FeaturesUtil-Get.
Source repository is at https://github.com/perlancar/perl-Module-FeaturesUtil-Get.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Module-FeaturesUtil-Get
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.
Module::Features
This module does not check whether a feature declaration is valid or whether a feature set specification is valid. To do that, use Module::FeaturesUtil::Check's check_features_decl and check_feature_set_spec.
check_features_decl
check_feature_set_spec
perlancar <perlancar@cpan.org>
This software is copyright (c) 2021 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.
To install Module::FeaturesUtil::Get, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Module::FeaturesUtil::Get
CPAN shell
perl -MCPAN -e shell install Module::FeaturesUtil::Get
For more information on module installation, please visit the detailed CPAN module installation guide.