On Wed, Apr 9, 2008 at 2:39 PM, Kit Peters <[EMAIL PROTECTED]> wrote:
> Is there some compelling reason you can't just pass your parameters as
> a hashref?
>
> param_test({tom => "somestring", george => "anotherstring", ref => [EMAIL
> PROTECTED]);
>
> sub param_test {
> my $args = shift;
> croak "Usage: param_test($hashref)" unless ref $args eq 'HASH';
> ....
>
>
> }
as I understand it the best practice for readability is
param_test(tom => "somestring", george => "anotherstring", ref => [EMAIL
PROTECTED]);
sub param_test {
my %args = @_;
croak <<INSTRUCTIONS unless 3 == grep { exists $args{$_}} qw/tom george ref/;
please refer to thread on KCLUG mailing list
INSTRUCTIONS
...
}
--
bringing useful insights from Computer Science to the larger world
_______________________________________________
kc mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/kc