NAME
CSAF::Util::List - (Mojo like) collection utility
SYNOPSIS
use CSAF::Util::List;
my $collection = CSAF::Util::List->new( qw[foo bar baz] );
DESCRIPTION
CSAF::Util::List is a collection utility.
METHODS
- TO_JSON
-
Alias for "to_array".
- add
-
Alias for "item".
- each
-
Evaluate callback for each element in collection.
foreach my $item ($c->each) { [...] } my $collection = $c->each(sub {...}); $c->each(sub { my ($value, $idx) = @_; [...] });
- first
-
Get the first element of collection.
- grep
-
Filter items.
my $filtered = $c->grep(sub { $_ eq 'foo' });
- item
-
Add a new item in collection.
$c->item('foo'); $c->item(sub {...});
- items
-
Get the list of collection items.
- join
-
Join elements in collection.
$c->join(', ');
- last
-
Get the last element of collection.
- map
-
Evalutate the callback and create a new collection.
CSAF::Util::List->new(1,2,3)->map(sub { $_ * 2 });
- new
-
Create a new collection.
my $c = CSAF::Util::List->new( [foo bar baz] );
- size
-
Number of item elements.
- to_array
-
Return the collection array.
SUPPORT
Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker at https://github.com/giterlizzi/perl-CSAF/issues. You will be notified automatically of any progress on your issue.
Source Code
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://github.com/giterlizzi/perl-CSAF
git clone https://github.com/giterlizzi/perl-CSAF.git
AUTHOR
Giuseppe Di Terlizzi <gdt@cpan.org>
LICENSE AND COPYRIGHT
This software is copyright (c) 2023-2024 by Giuseppe Di Terlizzi.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.