note
rinceWind
<p>I very rarely use $1, $2, etc. these days, as I find they're a source of bugs for the unwary. This is mainly owing to the very special type of binding, a consequence of which is that, in the event of a failure to match, they retain their <em>previous</em> values.</p>
<p>Instead, I capture to lexical variables. In your case, a single lexical array will do:</p>
<code>
my @answers;
my $re = qr/Title: (.*?), Author: (\w+) (\w+)$/; # 3 groups here
while (my @results = $text =~ /$re/mgc) {
my %ans;
push @answers, \@results;
}
</code>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-144850">
<p><small>--<br /><br />Oh Lord, won’t you burn me a Knoppix CD ?<br />
My friends all rate Windows, I must disagree.<br />
Your powers of persuasion will set them all free,<br />
So oh Lord, won’t you burn me a Knoppix CD ? <br /> <em>(Missquoting Janis Joplin)</em></small></p>
</div></div>
600423
600423