How to restart all hashes and arrays halfway through script

Discussion in 'Perl Misc' started by Ken Soon, May 11, 2007.

  1. Ken Soon

    Ken Soon Guest

    Hi,
    I am using dynamic arrays and hashes to store data. The names of the hashes
    and arrays changes to a certain groups of names and there are alot of names.

    Then i did some operations on this data with file::find, write to some files
    and others....
    However, as i continue on to another new operation on those hashes and
    arrays, somehow all the values are gone or different (I'm not sure yet
    whether is gone or different as I'm having trouble debugging to find out the
    confirmed erroneous output)
    Thus I am hoping if there such a thing to reset everything before i start on
    that next operation. (as if i am restarting the script at that point)

    Hmm all this sound abit weird though but i guess it is because haven't been
    able to debug the problem.

    hope my point is clear :X
    Ken Soon, May 11, 2007
    #1
    1. Advertising

  2. On May 11, 8:26 am, "Ken Soon" <> wrote:
    > I am using dynamic arrays and hashes to store data. The names of the hashes
    > and arrays changes to a certain groups of names and there are alot of names.


    It sounds to me like you are saying you are using symbolic references.

    This is probably the cause of you problem. Stop doing it and your
    problems will probably go away.

    >
    > Then i did some operations on this data with file::find, write to some files
    > and others....
    > However, as i continue on to another new operation on those hashes and
    > arrays, somehow all the values are gone or different (I'm not sure yet
    > whether is gone or different as I'm having trouble debugging to find out the
    > confirmed erroneous output)
    > Thus I am hoping if there such a thing to reset everything before i start on
    > that next operation. (as if i am restarting the script at that point)


    Hey, a SAQ! But you really do _not_ want the reset() function. Declare
    all your variables as lexically in the smallest applicable scope and
    you'll probably find your problem goes away.

    > Hmm all this sound abit weird though but i guess it is because haven't been
    > able to debug the problem.


    Lots of global variables and symbolic references will do that.

    > hope my point is clear :X


    Your point would be much clearer if you'd made it by showing us a
    _minimal_ but _complete_ (strict, warning-free) script that you'd run
    and found to reproduce the problem you are having.
    Brian McCauley, May 11, 2007
    #2
    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. jpw
    Replies:
    0
    Views:
    336
  2. kazaam
    Replies:
    12
    Views:
    268
    Matthias Wächter
    Sep 13, 2007
  3. Tim O'Donovan

    Hash of hashes, of hashes, of arrays of hashes

    Tim O'Donovan, Oct 27, 2005, in forum: Perl Misc
    Replies:
    5
    Views:
    208
  4. mrstevegross
    Replies:
    3
    Views:
    134
    Tad J McClellan
    Nov 11, 2008
  5. SM
    Replies:
    6
    Views:
    106
    Gregor Kofler
    Jun 1, 2008
Loading...

Share This Page