in reply to Re: Re: Package variables and Parse::RecDescent
in thread Package variables and Parse::RecDescent

The problem is that your grammar might look to you like a piece of code but is in fact just a string. You could move the definition of that string to any prior place in your program, it doesn't make any difference to Parse::RecDescent (P::RD).

Your grammar (the string) is taken apart into pieces (parsed) in P::RD and then the code to do the actual work is produced - outside your lexical scope. So apparently it can't access any lexical variables in this scope. The documenation of P::RD says to that:

The action executes within a special namespace belonging to the active parser, so care must be taken in correctly qualifying variable names

-- Hofmator

  • Comment on Re3: Package variables and Parse::RecDescent