in reply to repeated regex capture
If the PATTERN contains parentheses, additional list elements are created from each matching substring in the delimiter.
From how you've coded that, your split values are actually '' and your delimiters are the elements you are interested in.
Better is subjective, but I might do the split on any character followed by an A:
@parts=split(/(?=A)/,"A2ABA45");
You could also use a regular expression with the g modifier in list context and no capturing:
@parts = "A2ABA45" =~ /A[^A]*/g
That is less obvious to the neophyte, though. See Global matching.
|
|---|