Data::Perl(3pm)

Data::Perl3pm

Base classes wrapping fundamental perl data types.

Usage

  use Data::Perl;
  my $array = array(1,2,3, qw/a b c/);
  $array->count; # 6
  my @elements = $array->grep(sub {/b/}); # (b)
  my $hash = hash(a => 1, b => 2);
  $hash->keys; # ('a', 'b');
  my $number = number(5);
  $number->add(10); # 15
  my $string = string("foo\n");
  $string->chomp; # return 1, chomps string
  my $counter = counter();
  $counter->inc; # counter is now 1
  my $sub = code(sub { 'foo' });
  $sub->execute; # returns 'foo'
  $foo

Version

version 0.002011

Overview

Data::Perl is a collection of classes that wrap fundamental data types that exist in Perl. These classes and methods as they exist today are an attempt to mirror functionality provided by Moose's Native Traits. One important thing to note is all classes currently do no validation on constructor input.

Data::Perl is a container class for the following classes:

•

Data::Perl::Collection::Hash

•

Data::Perl::Collection::Array

•

Data::Perl::String

•

Data::Perl::Number

•

Data::Perl::Counter

•

Data::Perl::Bool

•

Data::Perl::Code

Alpha API

The API provided by these modules is as of now considered alpha and undecided. The API WILL change. If you are writing code that you will not touch again for years, do not use this until this warning is removed.

Provided functions

Data::Perl exports helper constructor functions to interface with the above classes:

•

hash(key, value, ...)

Returns a Data::Perl::Collection::Hash object initialized with the optionally passed in key/value args.

•

array(@args)

Returns a Data::Perl::Collection::Array object initialized with the optionally passed in values.

•

string($arg)

Returns a Data::Perl::String object initialized with the optionally passed in scalar arg.

•

number($arg)

Returns a Data::Perl::Number object initialized with the optionally passed in scalar arg.

•

counter($arg)

Returns a Data::Perl::Counter object initialized with the optionally passed in scalar arg.

•

bool($arg)

Returns a Data::Perl::Bool object initialized with the truth value of the passed in scalar arg.

•

code($arg)

Returns a Data::Perl::Code object initialized with the optionally passed in scalar coderef as an arg.

Thanks

Much thanks to the Moose team for their work with native traits, for which much of this work is based.

Maintainer

Toby Inkster <[email protected]> since version 0.002010.

Contributors

•

Graham Knop <[email protected]>

•

Jon Portnoy <[email protected]>

•

[email protected] <[email protected]>

•

Matt Phillips <[email protected]>

•

Toby Inkster <[email protected]>

Releases

7 releases since Debian 8 (Jessie); the text changed 4 times.

  1. 8–9
  2. 10
  3. 11
  4. 12–13
  5. Arch

Author

Matthew Phillips <[email protected]>

From perl-data-perl 0.002011-8 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.