in reply to How do I efficiently predeclare a hash with a set of keys
This is concise and saves a little space by not allocating any to the values.* The keys however still exist and test as such with exists.
my %set; undef @set{ 5,6,8..53,62..106 };
Update: This used to make a difference at some point in the past, but it no longer does (circa. 5.8.8 and possibly before).
The null list assignment method others have described my %set; @set{ ... } = (); is equal in memory usage and actually slightly faster. Thanks to bart++ for bringing this to my attention.
If you haven't voted on this node yet, please downvote it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I efficiently predeclare a hash with a set of keys
by bart (Canon) on May 19, 2007 at 09:30 UTC | |
by BrowserUk (Patriarch) on May 19, 2007 at 10:07 UTC | |
|
Re^2: How do I efficiently predeclare a hash with a set of keys
by lupey (Monk) on May 18, 2007 at 19:42 UTC |