in reply to Best practices for passing in function arguments?

The two alternatives are not equivalent, so choose whichever matches most closely to the useful parameters of your function.

Dum Spiro Spero
  • Comment on Re: Best practices for passing in function arguments?

Replies are listed 'Best First'.
Re^2: Best practices for passing in function arguments?
by andrewkl (Novice) on Dec 09, 2015 at 19:40 UTC
    Hi,
    I guess my question is: Does it make sense to pass in an array that contains only one item (a ref to a hash). That array will always have only 1 item.

    Or is it better to directly pass in the hash array (Scenario 2)

    Thanks
    --Andrew

      Will the subroutine ever be expected to perform its task on a list of hashes? Then an array would make sense. Otherwise it seems a needless complication. Which is repeating what I said before. It's your subroutine; YOU figure out how you want to use it.

      Dum Spiro Spero
        Hi,
        The processing of the list of hashes is handled in bar(), not foo().
        I think scenario 2 is makes more sense, but just wanted to see what others think.
        Thanks
        --Andrew