in reply to Perl store as variables regex matches for use outside of loop.

foreach (<DATA>) { my $re = qr/($book|$title)/; next unless /$re/; push @matches, [$1, $_, $re]; print; }

This saves the portion of the string that was captured, the string that matched, and the regexp that succeeded.


Dave

  • Comment on Re: Perl store as variables regex matches for use outside of loop.
  • Download Code