#!/usr/bin/perl -w use warnings; use strict; sub processDir { my $args = shift; # note, default for shift here is @_; my $ret = qx($args->{script} $args->{dir}); chomp($ret); print qq(Output:"$ret"\n) if $args->{verbose}; } # Normally via environment variable my $script = "echo -e"; # Normally via glob and processing in this script my @dirs = qw(dir1 dir2 dir3); # Normally via Getopt::Long my $verbose = 1; for my $dir (@dirs) { # Do some stuff, then: processDir( { dir => $dir, script => $script, verbose => $verbose } ); # which would be exactly the same as: processDir( { script = > $script, dir => $dir, verbose => $verbose } ); # or this: processDir( { verbose => $verbose, script => $script, dir => $dir } ); # or any other combination you can think of. } #### sub contains { my $self = shift; my %args = @_ == 1 ? ( date => shift ) : @_; $args{date} ||= 'today'; $args{style} ||= $self->{_style}; croak 'Unknown parameter present' if scalar(keys(%args)) > 2; ... }