in reply to Re^3: How we can separate a backref from a digit?
in thread How we can separate a backref from a digit?

It's an unexpected result.
  • Comment on Re^4: How we can separate a backref from a digit?

Replies are listed 'Best First'.
Re^5: How we can separate a backref from a digit?
by Jenda (Abbot) on Mar 18, 2011 at 11:13 UTC

    Unexpected to you. Variable interpolation happens before the regular expression is parsed and compiled so there is no difference between

    $a=1; print "Match\n" if "aa1" =~ /^(a)\1$a$/; # not match!
    and
    print "Match\n" if "aa1" =~ /^(a)\11$/; # not match!
    or
    $a='\11'; print "Match\n" if "aa1" =~ /^(a)$a$/; # not match!
    If it did not work like this you could not build regular expressions out of parts stored in variables.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

      I know that variable interpolation happens before the regular expression is parsed, but I think, Perl must report regarding using a backreference with incorrect number (11).
Re^5: How we can separate a backref from a digit?
by ikegami (Patriarch) on Mar 18, 2011 at 08:14 UTC

    What would you expect '\1'.'1' to give?