use Data::Dumper; chomp(my $black = ); my $white = ($black eq 'oda') ? 'yukiko' : 'oda'; my ($b_num, $w_num) = (0, 0); foreach (1..8) { chomp($_ = ); my @array = split('', $_); my @b_arr = grep {$_ eq 'b'} @array; my @w_arr = grep {$_ eq 'w'} @array; $b_num += scalar(@b_arr); $w_num += scalar(@w_arr); } print(($b_num > $w_num) ? $white : $black); print "\n";