Are file scoped variables in a module duplicated with each class instantiation?

Discussion in 'Perl Misc' started by sln@netherlands.com, Dec 11, 2008.

  1. Guest

    I have a large hash that is file scoped, a lexical in the module.
    Have to make quite a few instantiations of the class.
    Is the file scoped lexical hash duplicated each time?
    I wouldn't think so but does anybody know the quick answer?

    Thanks!

    sln
    , Dec 11, 2008
    #1
    1. Advertising

  2. Guest

    wrote:
    > I have a large hash that is file scoped, a lexical in the module.
    > Have to make quite a few instantiations of the class.
    > Is the file scoped lexical hash duplicated each time?
    > I wouldn't think so but does anybody know the quick answer?


    Not unless you specifically do something which causes it be
    duplicated.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    The costs of publication of this article were defrayed in part by the
    payment of page charges. This article must therefore be hereby marked
    advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
    this fact.
    , Dec 11, 2008
    #2
    1. Advertising

  3. Jim Gibson Guest

    In article <>,
    <> wrote:

    > I have a large hash that is file scoped, a lexical in the module.
    > Have to make quite a few instantiations of the class.
    > Is the file scoped lexical hash duplicated each time?
    > I wouldn't think so but does anybody know the quick answer?


    No. There is only one hash. Your file gets read and compiled only once.
    There is only one lexical variable with the name of your hash. Any
    instance of your class calls the methods that are defined in your class
    file. Each of those methods will access the same lexical variable for
    your hash. There is only one.

    --
    Jim Gibson
    Jim Gibson, Dec 11, 2008
    #3
  4. Guest

    Thank you!

    sln
    , Dec 11, 2008
    #4
    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. Mark
    Replies:
    4
    Views:
    7,928
    mike_treseler
    Nov 9, 2004
  2. Madhav
    Replies:
    4
    Views:
    299
    Kenny McCormack
    Jan 8, 2006
  3. Madhav
    Replies:
    27
    Views:
    548
    Dave Thompson
    Jan 16, 2006
  4. Replies:
    1
    Views:
    559
    Salt_Peter
    Dec 25, 2006
  5. Pavel Smerk
    Replies:
    1
    Views:
    120
    Logan Capaldo
    Aug 3, 2006
Loading...

Share This Page