in reply to Passing array into a hash
What I usually do is to have a single parameter that is a hashref. For example:
use strict; use warnings; errors( { 'all_msgs' => 'foo', 'msg_subject' => 'bar', } ); sub errors { my $args = shift; my $all = $$args{'all_msgs'} || ''; ... }
A few things to notice here, and they’re partly just stylistic:
In this example, the first (and only) argument to the subroutine is “a reference to a hash,” otherwise known simply as a “hashref.” Perl uses the notion of a “ref” quite extensively, allowing you to build up arbitrarily complex data structures.