Discussion Locked

Perl: Passing parameters in hashes

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

The 6/24 Perl e-newsletter explained why, if your subroutine has a number of optional parameters, you should consider passing those parameters as key-value pairs in a hash. Do you pass parameters to routines using hashes? If not, do you think you might after reading the tip?

If you aren't already subscribed to the Perl e-newsletter, visit our e-newsletter subcenter to sign up for this free TechMail today:
http://builder.com.com/techmails.jhtml?repID=u001

1 reply

by twirdlock

I frequently set up a %config_hash and use it to contain program configuration info to be passed to subroutines.

I have PERL programs that read in several .XML config files:
- systems-wide information
- information specific to a given machine
- information specific to a given script or program.

This allows me to put configuration info where I have to change it the least and still allow programs to work properly on whatever machine I chose to run them on.

This discussion is closed to new replies.