in reply to How we can link/access the variables of different module in main script without defining variable as global.. ??

This line:

my @array = <FILE>;

...creates a lexically scoped variable named @array, which is actually a completely different variable from the package global promised to Exporter, named @array. The package global's full name is @xyz::array... and it doesn't exist in your program. Aside from telling Exporter that you intend to export it, you never declare it nor populate it with any value.

You would be able to export @array if it were declared with our instead of my; lexical variables cannot be exported, while package globals may be. Exporting variables is usually the wrong approach though, but it is possible.


Dave

  • Comment on Re: How we can link/access the variables of different module in main script without defining variable as global.. ??
  • Select or Download Code