NAME
Full::Pragmata - common pragmata for Perl scripts and modules
SYNOPSIS
# in your script or module:
use Full::Pragmata;
# use strict, warnings, utf8 etc. are all now applied and in scope
DESCRIPTION
Perl has many modules and features, including some features which are somewhat discouraged in recent code.
This module attempts to provide a good set of functionality for writing code without too many lines of boilerplate. It has been extracted from Myriad::Class so that it can be used in other code without pulling in too many irrelevant dependencies.
Language features
The following Perl language features and modules are applied to the caller:
no indirect
Syntax::Keyword::Defer - or the standard Perl built-in defer since
:v2
Syntax::Operator::Equ - added in
:v2
Future::AsyncAwait::Hooks - added in
:v2
provides "blessed" in Scalar::Util, "weaken" in Scalar::Util, "refaddr" in Scalar::Util
provides "min" in List::Util, "max" in List::Util, "sum0" in List::Util
provides "uniqstr" in List::Util - added in
:v2
provides "encode_json_text" in JSON::MaybeUTF8, "encode_json_utf8" in JSON::MaybeUTF8, "decode_json_text" in JSON::MaybeUTF8, "decode_json_utf8" in JSON::MaybeUTF8, "format_json_text" in JSON::MaybeUTF8
provides "encode_utf8" in Unicode::UTF8, "decode_utf8" in Unicode::UTF8
In addition, the following core features are enabled:
Constraints and checks
Data::Checks is imported with the following constraints available:
Defined
Object
Str
Num
StrEq
NumGT
NumGE
NumLE
NumLT
NumRange
NumEq
Isa
ArrayRef
HashRef
Callable
Maybe
Any
All
Note that Data::Checks provides the underlying support for constraints, but actual usage involves a combination of other modules:
Field constraints
These are supported through Object::Pad::FieldAttr::Checked:
package Example;
use Full::Class qw(:v2);
field $checked :Checked(Str);
Other features
This also makes available a Log::Any instance in the $log
package variable, and for OpenTelemetry support you get $tracer
as an OpenTelemtry::Tracer instance.
VERSIONING
A version tag is required:
use Full::Pragmata qw(:v1);
Currently :v1
is the only version available. It's very likely that future versions will bring in new functionality or enable/disable a different featureset, or may remove functionality or behaviour that's no longer appropriate.
AUTHOR
Original code can be found at https://github.com/deriv-com/perl-Myriad/tree/master/lib/Myriad/Class.pm, by Deriv Group Services Ltd. DERIV@cpan.org
. This version has been split out as a way to provide similar functionality.
LICENSE
Released under the same terms as Perl itself.