<div dir="ltr">Mike,<br><br>The behavior that you are describing is covered in Perl regular expressions tutorial at <a href="https://metacpan.org/pod/distribution/perl/pod/perlretut.pod#Extracting-matches">https://metacpan.org/pod/distribution/perl/pod/perlretut.pod#Extracting-matches</a>.<br><br>I personally leverage this a lot in the code that I write - especially to capture all occurrences of something into an array. In fact, I have gotten into the habit of trying to write my code in such a way to try to avoid using the regex variables like $1 and $2.<br><br>And Uri has a very good point about needing to include some way to verify that the regex actually matched and returned values. Not having that has caused me headaches with trying to figure out what went wrong with my code.<br><br>John Ellyson</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 17, 2020 at 6:04 PM Mike Flannigan <<a href="mailto:mikeflan@att.net">mikeflan@att.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Recently I found this bit of code that I wrote<br>
long ago. I am a little surprised this works<br>
($1 and $2 get transferred to the scalars).<br>
I don't write that way anymore, but I am<br>
leaving it that way in this program.<br>
<br>
<br>
use strict;<br>
use warnings;<br>
<br>
my $test = 'abcdefgh';<br>
my ($latm, $longm) = $test =~ /(ab).*(fg)/i;<br>
print "$latm, $longm\n";<br>
<br>
<br>
Prints this:<br>
ab, fg<br>
<br>
<br>
<br>
Mike<br>
_______________________________________________<br>
Houston mailing list<br>
<a href="mailto:Houston@pm.org" target="_blank">Houston@pm.org</a><br>
<a href="https://mail.pm.org/mailman/listinfo/houston" rel="noreferrer" target="_blank">https://mail.pm.org/mailman/listinfo/houston</a><br>
Website: <a href="http://houston.pm.org/" rel="noreferrer" target="_blank">http://houston.pm.org/</a><br>
</blockquote></div>