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

Not a bug.
  • Comment on Re^3: How we can separate a backref from a digit?

Replies are listed 'Best First'.
Re^4: How we can separate a backref from a digit?
by Serge314 (Acolyte) on Mar 18, 2011 at 08:06 UTC
    It's an unexpected result.

      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).

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