in reply to Can we do without auxiliary variable here?

Could someone explain where these matches come from?

Calling your second version with prefix_print('y'), I get "PyP", not "PyPP". I am testing with perl 5.12.2, default compile from source on linux.

The match returns two matches on my system:

  1. the 'y' at the end of the line
  2. then '' (.* can match nothing) at the end of the line

It would be an infinite loop (forever matching nothing at the end of the line) except for Repeated Patterns Matching a Zero length Substring

I can't imagine how you got "PyPP"

  • Comment on Re: Can we do without auxiliary variable here?