Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: 'grouping' substrings?

by revdiablo (Prior)
on Feb 01, 2006 at 16:42 UTC ( #527108=note: print w/replies, xml ) Need Help??


in reply to Re: 'grouping' substrings?
in thread 'grouping' substrings?

I dont know whether using $& is effecient or not.

Using $& is not efficient, and usually to be avoided. See the entry in perlvar for details.

Update: perhaps I was a bit imprecise. I'd say something that "imposes a considerable performance penalty on all regular expression matches" is inefficient, but I guess it depends on what type of inefficiency we're talking about.

Replies are listed 'Best First'.
Re^3: 'grouping' substrings?
by ikegami (Pope) on Feb 01, 2006 at 16:52 UTC

    That's not exactly true. $& is only inefficient if you have another regexp in your program which doesn't capture.

    However, it's use is discouraged, since captures can perform the same task without the "effect at a distance" of $&.

    In this case, just replace $& with $1, and you're set.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://527108]
help
Chatterbox?
[Lady_Aleena]: This is one of my oldest accounts on the web. 8)
[Corion]: Lady_Aleena: Hehe - I think this is also my oldest active account on the web. I have an old university email address but that only gets spam nowadays :)
Discipulus arrived at work 1 hour late.. he do not noticed the clock bell
[Lady_Aleena]: My Wikipedia account is 3 years - 10 days younger.
[fux]: Hi folks:) Lady_Aleena: congrats!
vrk takes a handful of cookies from the platter on the sideboard.
Discipulus is preparing a big party for his 15th
[Lady_Aleena]: Thanks fux. Happy 5 day anniversary! 8)

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2017-04-26 07:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (470 votes). Check out past polls.