in reply to How do I efficiently predeclare a hash with a set of keys
The most efficient way to initialize a hash (other than directly, i.e. %h = ( key => value, ...)) is to assign hash slices:
@set{5,6,8..53,62..106} = ();
(Note that this makes the values all undef.)
This technique works particularly well when using hashes as sets, as you are.
|
|---|