Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by rsFalse (Chaplain)
on Nov 07, 2018 at 12:30 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1225353]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 03:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found