|Pathologically Eclectic Rubbish Lister
Re^4: How to pass two lists to a sub?by hmerrill (Friar)
|on Nov 08, 2004 at 13:31 UTC
I respectfully disagree with both points.
I disagree that shift makes code less maintainable. I agree that you are forced to change the code when a parameter is added, but I'm hard-pressed to come up with any situations where adding parameters _shouldn't_ warrant changing the code. If you are changing what is coming in to a subroutine, are you not changing the function of the subroutine??? Being explicit about exactly what parameters a subroutine takes in is just being clear - in my mind that makes the code _more_ maintainable.
For what reason would you want to maintain the original @_ array? I can't see any reason that maintaining the original argument array has any advantage over individual arguments created by shift. I don't typically (ever?)change the values of parameters taken into a subroutine anyway (does anyone else?) so maintaining the original parameter list is really no different with shift than it is with assigning variables from @_.
Feel free to disagree with me - for now I can't see any merit to your exceptions to using "shift'.