in reply to Re: Alternative to "use constant" in multiple subroutines
in thread Alternative to "use constant" in multiple subroutines

Thanks. I'll go look up how to make a module; I've never done that before.

The reason the constant changes is as such: I'm parsing several different types of files based on how I'm called. The data is in rows & columns with different column headers between the files. So, depending on which subroutine I'm in (based on how I'm called) the constant TIME (referring to the column number) can take on different values.
  • Comment on Re: Re: Alternative to "use constant" in multiple subroutines

Replies are listed 'Best First'.
Re3: Alternative to "use constant" in multiple subroutines
by dragonchild (Archbishop) on May 01, 2003 at 21:34 UTC
    There's a much better way to do that. Use hashes. That's the canonical way to associate a string (like a column name) with a number (like a column number). :-)

    Of course, this isn't a reason not to learn modules. You should do that because it's the next step.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      Thanks; I don't know why I didn't think of hashes. I probably did, but dismissed them for some dumb reason. I'm going to do it the hash way b/c that Seems Best - but I promise to learn modules, too. *grin*