For the given string example: <a><b><c><d><e><f><g>
I'd like to write an expression that will repeatedly match the first 5 <(?)>
tokens and put them in $1, $2, $3, $4 and $5.
The naive implementation would be of course: /<(?)><(?)><(?)><(?)><(?)>/
But back in the day I remember doing something like /(<(?)>:5)/
instead.
I'm having a hard time finding this syntax.
Can anyone help?
Thanks.
perl -wE '$_="<a><b><c><d><e><f><g>"; say /<(.)>/g;'
Will give all the matches. It's just a matter of getting a slice:
my @tokens = (/<(.)>/g)[0 .. 4];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With