|We don't bite newbies here... much|
Re: Collecting all values with shiftby erikharrison (Deacon)
|on Aug 30, 2002 at 04:27 UTC||Need Help??|
If you are not sure of the number of args, just assign to an array
Why not use @_ directly, you may ask? Well, first, @_ has magical powers. Second, it's less readable.
In fact, ask yourself why the sub has a variable number of args - is it trying to do to much? If so, then maybe you ought to consider breaking the function down into smaller bits with more clearly defined purposes
If the function has a clear need for multiple args, it may still be true that the first couple of args have a defined purpose and the remainder of the args define a variable length additional data. In that case, consider naming those important initial args in a useful way, leaving the remainder in a list.
This has the added benefit of promoting useful information out of the collection of the list to a more important looking scalarCheers,
Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet