List::Util

 

use List::Util;
use List::Util qw(first max maxstr min minstr reduce shuffle sum);

sub test {
my @numbers = (1, 2, 3, 4, 5, 6, 7);

# Get first element
my $first_number = first { defined($_) } @numbers;
print $first_number, "\n";

# Get max element
my $max_number = max @numbers;
print $max_number, "\n";

# Shuffle, reorder
my @shuffle_numbers = shuffle @numbers ;
print @shuffle_numbers, "\n";

# Sum
my $sum = sum @numbers;
print $sum, "\n";

# Reduce

}

&test() ;

1 ;



 

posted on 2011-11-28 16:52  perlman  阅读(1038)  评论(0编辑  收藏  举报

导航