Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Polish Prefix Calculator

by Anonymous Monk
on Oct 04, 2012 at 21:38 UTC ( #997329=note: print w/replies, xml ) Need Help??

in reply to Polish Prefix Calculator

What does "++", instead of "+", do in regex parts in the matching portion without /e?

If you are going to use smartmatch, then should mention the minimum perl version for default use. It was not available as any other operator, say "~", without use v5.10.1; in perl 5.10.

Replies are listed 'Best First'.
Re^2: Polish Prefix Calculator
by protist (Monk) on Oct 05, 2012 at 05:31 UTC

    ++ matches possessively. This means that it will hold on to what it finds and not backtrack if the match fails with the current amount of matching handled by ++.

    Contrast this with A+, where it will attempt a match of a maximum amount of As, then if the match fails, an A will be "given up" by A+, and a match will be attempted again with one less A. In the case of a failing match, if ++ will suit your needs, ++ is often many times more efficient (faster at failing when it does fail to match).

    In some cases, the difference between + and ++ is trivial. In other cases they are not logically equivalent. Such as in:

    /A++A/ and /A+A/ # /A++A/ should never find a match, as A++ prevents A from being match +ed after it.

    As a matter of good practice and efficiency, I use ++ wherever possible. I do the same with *+

      Thanks for the explanation. (Note to self: possessive quantifiers were introduced in perl 5.9.5.)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997329]
[mz2255]: I'm trying to post a question to "seekers of perl wisdom" but always getting a permission denied when I want to submit. There are no links in my post...
[ambrus]: again? someone complained about this just a few days ago (although eventually they could post)
[choroba]: Can you post the question in mz2255's scratchpad?
[ambrus]: Corion, if you're here, can you check the spam filter logs to see what's triggering this time?
[ambrus]: Petroza had trouble posting yesterday, but has posted Issues Fetching URL with a variable token since.
[mz2255]: Yes, just edited the scratchpad. Not sure if I'm doing something wrong, it's my first time.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2017-10-19 15:23 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (255 votes). Check out past polls.