in reply to Re: A 'print' at one spot changes a value at another
in thread A 'print' at one spot changes a value at another

In my actual program, the code to the function is generated at runtime, so I can't use a normal closure. Changing the respective 'my' to 'our' seems to have fixed the code, but I'm really bothered by the inconsistency that it works when I have that print statement.

(Maybe the print statement prevents it from making some optimization which isn't valid in the situation?)

  • Comment on Re^2: A 'print' at one spot changes a value at another

Replies are listed 'Best First'.
Re^3: A 'print' at one spot changes a value at another
by eric256 (Parson) on Aug 15, 2005 at 14:03 UTC

    The print statment lets perl know to close on the $sep variable. Without the print, perl doesn't know you want to access $sep because it doesn't look inside the eval. Changing to our makes $sep global so that it will always be available, not just when perl sees a function is going to use it.


    ___________
    Eric Hodges