Regexp::MatchContext

Regexp::MatchContext is Perl module to replace (and improve) $MATCH, $PREMATCH, and $POSTMATCH
Download

Regexp::MatchContext Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Damian Conway
  • Publisher web site:
  • http://search.cpan.org/~dconway/

Regexp::MatchContext Tags


Regexp::MatchContext Description

Regexp::MatchContext is Perl module to replace (and improve) $MATCH, $PREMATCH, and $POSTMATCH Regexp::MatchContext is Perl module to replace (and improve) $MATCH, $PREMATCH, and $POSTMATCHSYNOPSIS use Regexp::MatchContext -vars; $str = m/(?p) d+ /; print "Before: $PREMATCHn"; print "Matched: $MATCHn"; print "After: $POSTMATCHn"; $MATCH = 2 * $MATCH; # substitute into original $strThe English.pm module provides named aliases for Perl's built-in $`, $& and $' variables: $PREMATCH, $MATCH, and $POSTMATCH. Unfortunately, those aliases suffer the same problems as their originals: they degrade the performance of every single regex in your program, even if you're only using them to get information about a single match.This module also provides $PREMATCH, $MATCH, and $POSTMATCH, but in a way that only impacts the performance of matches that you specify. That is, these three variables are only set if the most recently matched regex contained the special (non-standard) meta- flag: (?p).That is: use Regexp::MatchContext -vars; $str = 'foobarbaz'; $str =~ /(?p) foo /x; # $PREMATCH contains 'foo' # $MATCH contains 'bar' # $POSTMATCH contains 'baz' $str =~ / foo /x; # $PREMATCH, $MATCH, and $POSTMATCH all undefThe (?p) marker can be placed anywhere within the regex and, except for setting the three context variables on a successful match, is otherwise totally ignored.Requirements:· Perl Requirements: · Perl


Regexp::MatchContext Related Software