while (@x = /($regex)/gc) { push @buffer, [ @x ]; # Or, if you localize (my) @x, push @buffer, \@x ; }