FAQ
The match vars are associated with the regexp that last matched
successfully. In the case of $str =~ $qr or /$qr/, since the $qr could
be used in multiple scopes that need their own sets of match vars, the
$qr is cloned by Perl_reg_temp_copy as of change 30677/28d8d7f. This
happens in pp_regcomp before pp_match has stringified the LHS, hence
the bug. In short, /$gror/ is not equivalent to ($which = !$which) ? /
$gror/ : /$gror/, which is weird.

Attached is a patch, which admittedly is a hack, but fixes this
particular side effect of what is probably a bad design, by
stringifying the LHS in pp_regcomp, and having pp_match skip get-magic
in such cases. A real fix far exceeds my capabalities, and would also
be very intrusive according to <http://www.nntp.perl.org/group/perl.perl5.porters/2007/03/msg122415.html
.

Search Discussions

  • Rafael Garcia-Suarez at Dec 14, 2009 at 11:27 am
    Thanks, applied to bleadperl as change 69dc4b30f4725ad5f212d45d3c856ac1caaacf17

    2009/12/13 Father Chrysostomos <sprout@cpan.org>:
    The match vars are associated with the regexp that last matched
    successfully. In the case of $str =~ $qr or /$qr/, since the $qr could be
    used in multiple scopes that need their own sets of match vars, the $qr is
    cloned by Perl_reg_temp_copy as of change 30677/28d8d7f. This happens in
    pp_regcomp before pp_match has stringified the LHS, hence the bug. In short,
    /$gror/ is not equivalent to ($which = !$which) ? /$gror/ : /$gror/, which
    is weird.

    Attached is a patch, which admittedly is a hack, but fixes this particular
    side effect of what is probably a bad design, by stringifying the LHS in
    pp_regcomp, and having pp_match skip get-magic in such cases. A real fix far
    exceeds my capabalities, and would also be very intrusive according to
    <http://www.nntp.perl.org/group/perl.perl5.porters/2007/03/msg122415.html>.


    --
    "You don't mean odds and ends, you mean des curieux et des bouts",
    corrected the manager.
    -- Terry Pratchett, Hogfather

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedDec 13, '09 at 8:55p
activeDec 14, '09 at 11:27a
posts2
users2
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase