"be consistent" | |
PerlMonks |
How to access last capture groups outside regex using interpolation but w/o using re 'eval'?by rsFalse (Chaplain) |
on Jun 16, 2020 at 20:10 UTC ( [id://11118150]=perlquestion: print w/replies, xml ) | Need Help?? |
rsFalse has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I want solve this problem using regexes: Given a "sorted" target string and a sequence of sizes of groups of equal consecutive characters, find and output characters from a string which corresponds to each group. I wrote a code, which glues smaller regexes to a bigger one, and uses re-eval ((?{ ... })). I use a "stack" array for saving captured characters, and use push/pop to manipulate it. Also I used $^N variable interpolating it inside double-quotes. This fails to run without "use re 'eval'". How can I overcome it? Any alternatives to $^N for access a last captured group outside of regex? Any ideas of alternative solutions for a given problem? Code: OUTPUT:
Back to
Seekers of Perl Wisdom
|
|