my $connButton = $mw->Button( -text => "Connect", -command => sub { my @networks = grep { defined } @checkbox; if(@networks == 1) { say $networks[0]; } else { say "Select one network, please."; } }