my @array = (1, 2, 3, 4, 5);
my @new_array = map { $_ * 2 } @array;
# 輸出:(2, 4, 6, 8, 10)
my @array = (1, 2, 3, 4, 5);
my @filtered_array = grep { $_ % 2 == 0 } @array;
# 輸出:(2, 4)
my @array = (5, 3, 1, 4, 2);
my @sorted_array = sort { $a <=> $b } @array;
# 輸出:(1, 2, 3, 4, 5)
my @array = (1, 2, 3, 4, 5);
splice @array, 2, 0, 6;
# @array 現在為 (1, 2, 6, 3, 4, 5)
my @array = (1, 2, 3, 4, 5);
my $string = join ', ', @array;
# 輸出:'1, 2, 3, 4, 5'
my @array = (1, 2, 3, 4, 5);
my @reversed_array = reverse @array;
# 輸出:(5, 4, 3, 2, 1)
use List::MoreUtils qw(uniq);
my @array = (1, 2, 2, 3, 4, 4, 5);
my @unique_array = uniq @array;
# 輸出:(1, 2, 3, 4, 5)