List::Utils - Additional list utilities
use List::Utils qw(:all); print 'all "true", so to speak' if all(@data); print 'none true' if none(@data); print 'at least 1 false' if notall(@data); if (notall(@data)) { printf "as a matter of fact, %d are true and %d are false", true(@data), false(@data); } ok(index_for_which(sub { shift() eq 'hallowed' }, @violent_femme), 3); for (@required_fields) { my $search = $_; $required_fields_i{$_} = index_for_which ( sub { shift() eq $search }, $R ); } my $I = index_for_which(sub { length(shift()) == 8 }, \@violent_femme); my $r = _insert_after ($I, 'compound_insert', \@violent_femme ); # easier my $r = insert_after (sub { length(shift()) == 8 }, 'second_innsert', \@violent_femme ); # easiest my $r = insert_after_string ('be', 'very', \@violent_femme);
You know the things that Graham said could be implemented in Perl in the List::Util (part of Scalar::List::Util release) docs but didn't? Well, here they are.
all returns true if all arguments are true
all
none returns true if all arguments are false
none
notall returns true if any argument is false
notall
true returns how many elements are true
true
false returns how many elements are false
false
C<insert_before> must be written... for obvious reasons.
None by default. use List::Utils qw(:all) to import all subs.
use List::Utils qw(:all)
T. M. Brannon, <tbone@cpan.org>
perl(1).
To install List::Utils, copy and paste the appropriate command in to your terminal.
cpanm
cpanm List::Utils
CPAN shell
perl -MCPAN -e shell install List::Utils
For more information on module installation, please visit the detailed CPAN module installation guide.