foreach (@$array){ last if($_ =~ m/^\s/); push (@$array2, $_); }