Note: When key names start with an underscore, you should quote the key name as it may lead to issues with strict pragma.

I took a look at Class::Struct. My quick guess is that it takes each key you add in the struct method and auto-generates a setter and getter.

Code

$element_value = $obj->s; # element value $obj->s('new value');

In order for your object to work like this, you would need to create the setter and getters for each key. This can be done by the AUTOLOAD to create the getter/setter on the fly. Otherwise, it's pretty monotonous. For what it's worth, to save time, headaches, and use proven well tested code - use Moose.