note
dsheroh
<blockquote><i>Instead, use m/"(.*?)"/, which will stop matching as soon as it can.</i></blockquote>
Or, better (at least when you're going up to a single-character terminator), <i>be more explicit about what you actually want</i> by using a negated character class: <c>m/"([^"]*)"/</c>
<p>
If you want to match anything except a double-quote, tell Perl to match "anything except a double-quote" (<c>[^"]</c>), not "the shortest possible set of anything at all that happens to have a double-quote after it" (<c>.*?"</c>).
<p>
Also, more pragmatically, if there's more to your regex after this part, then you could get cases where <c>(.*?)"</c> will still contain double-quotes in the match if that's needed to make the "more after this part" work. Because it's more explicit about not matching double-quotes, <c>([^"]*)</c> will <i>never</i> have them in the match.
1227948
1227964