Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: Print A Sequence with Start codon and different Stop Codon

by Anonymous Monk
on Oct 28, 2015 at 12:08 UTC ( [id://1146257]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Print A Sequence with Start codon and different Stop Codon
in thread Print A Sequence with Start codon and different Stop Codon

should that be "(?{ code })" instead of "(??{ code })" ?
  • Comment on Re^4: Print A Sequence with Start codon and different Stop Codon

Replies are listed 'Best First'.
Re^5: Print A Sequence with Start codon and different Stop Codon
by Anonymous Monk on Oct 28, 2015 at 13:42 UTC

    Nope.

    "(??{ code })" is used so the regex fails and backtracks. It's the backtracking that finds every answer.

      perlre says:
      This is a "postponed" regular subexpression. It behaves in exactly the + same way as a (?{ code }) code block as described above, except that + its return value, rather than being assigned to $^R , is treated as +a pattern, compiled if it's a string (or used as-is if its a qr// obj +ect), then matched as if it were inserted instead of this construct.
      so what is treated as a pattern here? is it what "print $1" returns?

        The print returns 1, which becomes a pattern that will not be matched, so the regex fails and backtracks.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-16 05:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found