How can I access the variables in my script ($main::var)

S

Sean

Hi Folks,

I need to access some of the variables in my script. These variables are
used by methods called in packages that might be nested.
I have used $main::var. This does not seem to do job. Any sugestions?

Thanks,

Sean
 
T

Tad McClellan

Sean said:
I need to access some of the variables in my script.


What script?

We cannot help you with code that we cannot even see.

Have you seen the Posting Guidelines that are posted here frequently?

These variables are
used by methods called in packages that might be nested.
I have used $main::var. This does not seem to do job.


What does "not seem to do job" mean when you say it?

That is, what did you observe that led you to conclude that it
is not doing the job?

Delivering a diagnosis without being told any of the symptoms
is futile.

Any sugestions?


I suggest providing enough information so that we can help you.
 
G

gf

Hi Folks,

I need to access some of the variables in my script. These variables are
used by methods called in packages that might be nested.
I have used $main::var. This does not seem to do job. Any sugestions?

Sounds like a really good recipe for a really bad idea.

When I need to be able to write to variables in the main code block, I
pass them into the modules' subroutines as references. If a nested
routine needs access then pass the reference on to it via its
parameters.

I never attempt to refer to them directly because then it's another
spin on abusing globals and that's not good maintenance-wise.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,664
Latest member
RoseannBow

Latest Threads

Top