On Thu, Mar 10, 2016 at 04:25:17PM +0100, Ulrich Windl wrote: > >>> "Zefram via RT" <perlbug-followup@perl.org> schrieb am 10.03.2016 um 16:11 in > Nachricht <rt-4.0.18-31775-1457622680-1028.127684-94-0@perl.org>: > > Ulrich Windl wrote: > >>It would be useful in the original context. I tired to make this a one-liner: > >> my $index_by_name = sub { > >> my $hi = $header_i{(shift)}; > >> > >> die unless (defined($hi)); > >> return $hi; > >> }; > > > > my $index_by_name = sub { $header_i{(shift)} // die }; > > > > This is a defined-or situation, not defined-and. > > Thanks, I forgot "If no "return" is found and if the last statement is an expression, its value is returned." (wisdom from "man perlsub") You don't even need that; it works with an explicit return as well: sub {return $header_i {+shift} // die} AbigailThread Previous