The gem from the perlre page (which prasadbabu pointed you to) is to stay away from $& - it reads this:
Once perl sees that you need one of $&, $` or $' anywhere in the program, it has to provide them on each and every pattern match. This can slow your program down. The same mechanism that handles these provides for the use of $1, $2, etc., so you pay the same price for each pattern that contains capturing parentheses. But if you never use $&, etc., in your script, then patterns without capturing parentheses won't be penalized. So avoid $&, $', and $` if you can, but if you can't (and some algorithms really appreciate them), once you've used them once, use them at will, because you've already paid the price.

As I understand it, this means that from the point you invoke one of those evil 3, your program will cache (in your precious RAM) every text match it makes while the program is running - if you're parsing a large amount of data that's *nasty*!

There is no need in this case (and I don't recall ever finding a case that did need) to use $& - what you want is a specific part of the match (for that you could use round brackets) like this:

#!/usr/bin/perl -w use strict; my $string = qq{oCMenu.makeMenu('m40','','Files','','',100,20) oCMenu. +makeMenu('m41','m40','Periodic Reports','index.cfm?openaction=file_ar +chive.view&CONTENT_ID=BF764E84-ED11-EC57-40672E520082E823','',125,20) + oCMenu.makeMenu('m53','m40','Reference Documents','index.cfm?openact +ion=file_archive.view&CONTENT_ID=BF76E870-E7CC-515F-D4D5C3D4A210BB9A' +,'',125,20)}; $string =~ /Periodic Reports','([^']+)'/; print "Want to see:\n", "index.cfm?openaction=file_archive.view&CONTENT_ID=BF764E84-ED11-EC57- +40672E520082E823", "\n$1\n";
Here the $1 returns the portion between the first () in the match ($2 will return the second and so on...)

In reply to Re: RegEx Help - Look Behind by serf
in thread RegEx Help - Look Behind by awohld

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.