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
In reply to A dispatch table to match named params of a sub by neilwatson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |