Posted by Peter Palfrader aka Weasel on 2000-02-13
On Sat, Feb 12, 2000 at 11:55:21PM +0100, Kspansel@xxx.xxx wrote:
> That's kinda what I'm going for. But I want to check each element of an
> array and take action depending on which one it matched. So I need to know
> which one it matched. But..hmm..it's hard to explain what I'm thinking.
ok, how about this one:
my $input = something;
my %action;
$action{'print'} =
sub {
print "foo";
};
$action{'add'} =
sub {
$a = 2+2;
};
$action{'tic'} =
sub {
tac, toe..
};
if ( defined $action{$input} ) {
&{ $action{$input} };
} else {
print "luser\n";
}
--
Weasel http://www.cosy.sbg.ac.at/~ppalfrad/
PGP/GPG encrypted messages prefered. See my site or finger -l ppalfrad
Yes means No and No means Yes. Delete all files [Y]?
To signoff send a mail to listserver@xxxx.xx.xx with
"signoff tcg" in the body of your message.
Previous post | Next post | Timeline | Home