my (@a1, @a2); while () { /$some $regex ($with) ($parens)/; push @a1, $1; push @a2, $2; } print @a1, @a2;