package Mapx; use strict; use warnings; use Exporter qw( import ); our @EXPORT = qw( mapx DONE_MAP ); use Scalar::Util qw( reftype blessed ); use constant DONE_MAP => \&mapx; sub mapx(&@) { my $cb = shift; my @rv; for (@_) { my @x = $cb->(); last if @x == 1 && reftype($x[0]) && !blessed($x[0]) && $x[0] == DONE_MAP; push @rv, @x; } return @rv; } 1;