in reply to Re: Ordering of parameters - Re^9: Converting Unicode
in thread Converting Unicode
Apparently, I'm the only one who ever needs scores of variables passed into a single subroutine
No, you are certainly not the only one...
I recall writing a sub that took 20-odd parameters. It quickly got out of hand. At that time, I didn't know how to do it any other way.
If I have a sub that takes more than two required parameters and one optional parameter, I would use a hashref instead so I could pass a series of unordered, named parameters. However, if I got to that point, I would seriously question whether I had created a suboptimal fudge instead of a good design.
The one time I have recently wanted to pass many parameters to a sub was the components of an email (from name, email, recipient name, etc). I created a sub that accepted a hashref and then encapsulated the sub in a module so the functionality was clearly separate from the main code.
If you are writing subs that take lots of parameters, I suggest you ask yourself if there is a better way to do it. The answer, in any language, is probably yes.
|
|---|