my @picks = grep { ... } @menu; if ( 1 < scalar @picks ) { die "Too many options match your input, '$input'\n"; } $picked = $picks[0];