in reply to Re: Noob could use advice on simplification & optimization
in thread Noob could use advice on simplification & optimization

Aww! Much better! Thank you for taking the time to do this. I started cleaning things up, but my latest update was still felt too verbose and messy. I'm going to incorporate these suggestions as soon as I can, your changes make more sense and are more efficient. I am confused some on the scope of you're hashes, why are they able to be shared if they are not declared as global?
  • Comment on Re^2: Noob could use advice on simplification & optimization

Replies are listed 'Best First'.
Re^3: Noob could use advice on simplification & optimization
by thundergnat (Deacon) on May 07, 2012 at 17:48 UTC

    ?? The %tk and %s hashes ARE global. They are declared in the main scope.

    BTW, I updated the script a bit; fixed some errors (my errors) and tweaked some things here and there.

      I see. I'm missing a simple concept somewhere then, because I see they are declared with 'my'. Does this have a different behavior in your context? Also, I added several of your suggestions already and I'm working through the rest now.

        'my' variables are lexical to the enclosing block. Here, since the variables are declared in the MAIN package, outside of any block, they are global, or visible to all all blocks within the package MAIN.

        Declaring a variable with 'our' makes the the variable lexical to all enclosed blocks even across package boundaries.

        See perldoc -f my and perldoc -f our for more explanation.