in reply to Sharing a variable across multiple files

G'day bihuboliya,

"The changes made to the variable @my_var in 1.pl is not reflected in 2.pl. Please let me know where I am wrong."

2.pl loads a fresh copy of my_module.pm with our @my_var = (1..10); — it knows nothing about changes made by 1.pl.

"Please suggest if I should take any other approach."

While it's good that you've provided a minimal example to demonstrate the problem, we'll need to know a bit more about what you're trying to achieve in order to advise on a better approach. Some possibilities are (in no particular order):

[While Exporter was not the way to go here, your usage is generally not that good for any scenario. For future reference, see Selecting What to Export and What Not to Export.]

-- Ken

Replies are listed 'Best First'.
Re^2: Sharing a variable across multiple files
by bihuboliya (Acolyte) on Aug 07, 2013 at 11:01 UTC
    Hi Ken, thank you for the detailed answer :) I want to share quite a few number of variables across multiple files which act on those variables. Directly passing the variables would be little messy I suppose. You have directed me to various routes to get it done. I will explore them and revert back. Thanks for the time being. Regards, Anupam