in reply to Fastest way to test membership in a constant set
You don't show us how using a global hash fails for you, but here is an approach:
use strict; use vars qw(%IsMember); %IsMember = ('age' => 1, 'old' => 1, 'years' => 1);
Use it as:
if ($IsMember{age}) { print "'age' is a member\n" }; if ($IsMember{ego}) { print "'ego' is a member\n" };
For development, you can lock the hash keys by using Tie::Hash::FixedKeys.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fastest way to test membership in a constant set
by jettero (Monsignor) on Jul 26, 2007 at 15:48 UTC | |
by Corion (Patriarch) on Jul 26, 2007 at 15:55 UTC |