#!/usr/bin/perl -w BEGIN { print "Compile time\n"; } package Foo; use fields qw(some_attribute); sub new { return fields::new(@_); } sub test { my Foo $self = shift; # note the my Foo $self $self->{does_not_exist} = 1; } package main; my Foo $foo = Foo->new(); print "run time\n"; $foo->test(); print "ok\n"; __OUTPUT__ Compile time No such pseudo-hash field "does_not_exist" in variable $self of type Foo at test.pl line 16. #### Compile time run time No such pseudo-hash field "does_not_exist" at test.pl line 16.