http://www.perlmonks.org?node_id=812976


in reply to Re: Accessing main::Constant
in thread Accessing main::Constant

Thanks. It works fine.

I need another clarification, Is it possible to access a variable in main package like below,

package pq; . use constant { VAR => "main::$VAR" }; . . sub pr { print main::$VAR; print VAR; }

I'm getting error. So I thought, 'As the constants are expanded when compilation, it isn't working as what I expected'. $VAR is a our variable in main package.