use List::Part; my ( $in, $out ) = part { m/$hit/ } @pids;