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

Discussion in 'Perl Misc' started by Sean, Mar 7, 2007.

  1. Sean

    Sean Guest

    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
     
    Sean, Mar 7, 2007
    #1
    1. Advertising

  2. Sean <> 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
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Mar 8, 2007
    #2
    1. Advertising

  3. Sean

    gf Guest

    On Mar 7, 2:46 pm, "Sean" <> 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.
     
    gf, Mar 8, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alvin Bruney

    Threads.. Session var lost, App var ok

    Alvin Bruney, Dec 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    373
    rooster575
    Dec 2, 2003
  2. thomson
    Replies:
    10
    Views:
    2,510
    Eliyahu Goldin
    Jun 20, 2005
  3. thomson
    Replies:
    0
    Views:
    396
    thomson
    Jun 20, 2005
  4. Fred
    Replies:
    3
    Views:
    330
    Alf P. Steinbach
    Aug 10, 2003
  5. Alex Vinokur
    Replies:
    4
    Views:
    484
    Ron Natalie
    Sep 24, 2003
Loading...

Share This Page