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

Re: Greedy flip flop operator?

by hippo (Bishop)
on Apr 26, 2018 at 08:09 UTC ( [id://1213584]=note: print w/replies, xml ) Need Help??


in reply to Greedy flip flop operator?

Is there a way to have a greedy flip flop operator?

Not that I am aware of. However there are lots of ways to achieve the same effect. Here's one:

use strict; use warnings; use Test::More tests => 1; my $want = <<EOT; start text + 123 + 456 + 789 EOT my $out; while (<DATA>) { last unless (/^(start|\+)/); $out .= $_ } is ($out, $want); __DATA__ start text + 123 + 456 + 789 some other text not starting with +

If your actual data is different then you might have to try another approach but I think this should be fairly efficient.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found