in reply to
Passing a hash into a subroutine
There may be some confusion going on here. Will users of your Converter module actually have the parameters stored in a hash variable? Or do you just want to have your routine take "named parameters"? Most of the replies seem to have assumed the former, so for completeness I will assume the latter.
Sample code:
sub convert {
# Since this is an object method, the object is passed as first arg
+;
my $self = shift;
# now load the rest of the args into a hash
my %arg = @_;
if ($arg{"MIME-Type"} eq "application/ms-word") {
install_openofficedotorg()
...
}
There are some problems with this. If the caller passes an odd number of parameters, you'll get a warning on that = @_ assignment statement. It also is hard to catch typos in the parameter names, e.g. MIME_Type => "application/ms-word" would get silently ignored, because it has _ instead of -.
There are several modules, such as Params::Validate that help out when dealing with named parameters.