Scroll to navigation

CSAF::Util::List(3pm) User Contributed Perl Documentation CSAF::Util::List(3pm)

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

Alias for "to_array".
Alias for "item".
Evaluate callback for each element in collection.

    foreach my $item ($c->each) {
        [...]
    }
    my $collection = $c->each(sub {...});
    $c->each(sub {
        my ($value, $idx) = @_;
        [...]
    });
    
Get the first element of collection.
Filter items.

    my $filtered = $c->grep(sub { $_ eq 'foo' });
    
Add a new item in collection.

    $c->item('foo');
    $c->item(sub {...});
    
Get the list of collection items.
Join elements in collection.

    $c->join(', ');
    
Get the last element of collection.
Evaluate the callback and create a new collection.

    CSAF::Util::List->new(1,2,3)->map(sub { $_ * 2 });
    
Create a new collection.

    my $c = CSAF::Util::List->new( [foo bar baz] );
    
Number of item elements.
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-2025 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.

2025-09-03 perl v5.40.1