in reply to Converting Hashes to Objects
If you're not tied to creating objects, I found locking hashes quite good to prevent typos:
use Hash::Util 'lock_keys'; my $hash = h2o { foo => "bar", x => "y" }, qw/ more keys /; lock_keys $hash; print $hash->{ foo }, "\n"; # prints "bar" $hash->{ x } = "z"; # setter $hash->{batman} = 'secret'; # dies
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Converting Hashes to Objects
by haukex (Archbishop) on May 17, 2020 at 17:06 UTC | |
Re^2: Converting Hashes to Objects
by haukex (Archbishop) on May 17, 2020 at 21:07 UTC |
In Section
Meditations