in reply to multiple keys - one value
in thread using a hash of functions
This is a little clumsy, but you could have '?' => 'HELP', etc, then use a loop at startup that replaced non-code refs with the code ref of the hash indice the value side points to.
It doesn't completely solve the semantic problem, but if you rename a routine, you only have to touch it one place, and adding synonyms becomes trivial.
e-mail jcwren
It doesn't completely solve the semantic problem, but if you rename a routine, you only have to touch it one place, and adding synonyms becomes trivial.
--Chris#!/usr/local/bin/perl -w use strict; my %hash = ('HELP' => \&do_help, '?' => 'HELP', 'LIST' => \&do_list, 'SHOW' => 'LIST', 'TEST' => \&do_test, ); { while (my ($k, $v) = each (%hash)) { $hash {$k} = $hash {$v} if (ref $hash {$k} ne 'CODE'); } &{$hash {'HELP'}}; &{$hash {'?'}}; &{$hash {'LIST'}}; &{$hash {'SHOW'}}; &{$hash {'TEST'}}; } sub do_help {print "help\n"} sub do_list {print "list\n"} sub do_test {print "test\n"}
In Section
Seekers of Perl Wisdom