vek has asked for the wisdom of the Perl Monks concerning the following question:
Esteemed monks, I seek your wisdom.
If you have a lot of arguments that you need to pass to a subroutine, is it preferrable to pass & access them individually:
I'm starting to get some 'feature creep' in my code and keep adding subroutine arguments as the specifications change. I'm thinking at the very least if I pass by named parameter I'll have some 'self-documenting' code.
What do you do?
If you have a lot of arguments that you need to pass to a subroutine, is it preferrable to pass & access them individually:
Or pass & access by named parameter:do_stuff($foo, $bar, $foo_too, $bar_too, $foo_who_poo); sub do_stuff { my ($foo, $bar, $foo_too, $bar_too, $foo_who_poo) = @_; }
Or is it purely personal preference?do_stuff(one=>$foo, two=>$bar, three=>$foo_too, four=>$foo_who_poo); sub do_stuff { my %args = @_; }
I'm starting to get some 'feature creep' in my code and keep adding subroutine arguments as the specifications change. I'm thinking at the very least if I pass by named parameter I'll have some 'self-documenting' code.
What do you do?
Back to
Seekers of Perl Wisdom