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
none returns true if all arguments are false
notall returns true if any argument is false
true returns how many elements are true
false returns how many elements are false
C<insert_before> must be written... for obvious reasons.
None by default. use List::Utils qw(:all) to import all subs.
T. M. Brannon, <tbone@cpan.org>
perl(1).