Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How can I access the variables in my script ($main::var)

Reply
Thread Tools

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

 
 
Sean
Guest
Posts: n/a
 
      03-07-2007
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


 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      03-08-2007
Sean <(E-Mail Removed)> wrote:

> 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.


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
 
gf
Guest
Posts: n/a
 
      03-08-2007
On Mar 7, 2:46 pm, "Sean" <(E-Mail Removed)> wrote:
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
How can I access variables in my perl script from a sub in a module sm Perl Misc 3 01-04-2007 09:33 AM
How to construct new variables in a script from other variables and strings. gerry.brennan@gmail.com Perl Misc 9 05-12-2006 06:00 PM
Can you access Session Variables from Client Side Script? Craig G ASP .Net 3 01-26-2005 10:37 AM



Advertisments