http://www.perlmonks.org?node_id=1225353


in reply to Re: Where can I find more examples of use of Special Backtracking Control Verbs?
in thread Where can I find more examples of use of Special Backtracking Control Verbs?

Also once I used '(?{})' with '(*FAIL)' simply for traversing all characters of the string.
/.(?{ do_smth( $& ) })(*FAIL)/ for @lines;
This part:
/.(?{ do_smth( $& ) })(*FAIL)/
is similar to:
do_smth( $& ) while /./g;
, but it can not(?) be combined with 'for' into one short expression like:
do_smth( $& ) while /./g for @lines; # syntax error
Instead I should write:
do{ do_smth( $& ) while /./g } for @lines;
Another variant here was to concatenate all lines: my $concatenated_lines = join $some_concatenator, @lines. And then simply match. But imagine if the regex is more complex and can accidentally match a concatenator as well.
And another alternative here was to use eval within non-destructive substitution:
s/./ do_smth( $& ) /ger for @lines;
Note modifiers: e - for eval, and r - for non-destructiveness.
But imagine do_smth function returning long strings (e.g. ( ( ord $& ) % 2 ? $odds : $evens ) .= $& ) and it could possibly(?) slow down process.