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


in reply to Re^3: Repeating Code - there has GOT to be a better way!
in thread Repeating Code - there has GOT to be a better way!

Or even

#!/usr/bin/perl my %cmds = map { (/(.*)Cmd/) => { do $_ } } <*Cmd.pm>; use Data::Dumper; print Dumper \%cmds;
$ cat *Cmd.pm ; ./832111.pl %barCmd = ( # barCmd.pm BAR => 99, # ... ); %fooCmd = ( # fooCmd.pm FOO => 42, # ... ); $VAR1 = { 'bar' => { 'BAR' => 99 }, 'foo' => { 'FOO' => 42 } };