in reply to Re^2: Faster indexing an array
in thread Faster indexing an array
(2) But the real reason I'm writing is this remark:
"These days, I often go all the way to a $universal hashref, which makes it almost trivial to save and restore the program state."
(a) 'tis true that hash field names get autovivified and hence defeat "use strict", but if you have a known set of allowed names, you can strictify them yourself, using the "lock_keys" routine from Hash::Util.
(b) but you're reinventing perl objects. You might as well just do objects... then if you're using something moose-like, like Mouse or Moo, the "allowed names" get turned into a list of "has" lines.my %uni = map{ $_ => undef } @allowed_names; Hash::Util::lock_keys( %hash );
|
|---|