OK. Split seems to be the right answer - I'm not sure where my obsession with using a regex came from this morning. I think I was hoping to use it to do some level of validation of the input (just print out a warning and skip any lines which didn't match) but splitting then validating the results is more readable, if significantly longer.
In this case regexes probably weren't the best way to do it, but I still don't understand how to retrieve matched groups from a repeated group. For example:
Does not printmy @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"; }
1 2 3 4 5 6 7 8 9as I might have expected, but
2 6 9What am I missing?
In reply to Re: Matching a pattern two or four times
by Bilbo
in thread Matching a pattern two or four times
by Bilbo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |