my @list = map { ($_->[0]) x $_->[1] } @array; my $elem = $list[rand @list];