Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Where can I find more examples of use of Special Backtracking Control Verbs?

by rsFalse (Pilgrim)
on Nov 07, 2018 at 12:30 UTC ( #1225353=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1225353]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2019-02-19 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I use postfix dereferencing ...









    Results (105 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!