fields pragma, .
:
package MyPackage;
use fields qw/ foo bar /;
sub new { fields::new(shift) }
,
use MyPackage;
my MyPackage $p1 = MyPackage->new;
print $p1->{notpresent}, "\n";
No such class field "notpresent" in variable $p1 of type MyPackage at ...