http://www.perlmonks.org?node_id=1132487

neilwatson has asked for the wisdom of the Perl Monks concerning the following question:

Greetings,

I'm trying to craft a dispatch table that will feed a sub that uses named parameters ( my %args = @_ ). I've tried a few combinations, but nothing seems to come out right. What can I do?

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Test::More; my %sub = ( t01 => { name => \&mine, arg => [ qw/one first two second/ ] } ); $sub{t01}->{name}->( $sub{t01}->{arg} ); sub mine { my %args = @_; ok( $args{one} eq 'first', 'arg one' ); ok( $args{two} eq 'second', 'arg two' ); done_testing; }

Neil Watson
watson-wilson.ca