my @lines = ("a 1 2", "b 3 4 5 6", "c 7 8 9"); foreach (@lines) { my @list = m/^[a-z](\s+\d+)+/g; print @list, "\n"; }