use strict; use warnings; # Comment out unless 5.6+ package Bar; use vars qw/ $AUTOLOAD /; sub new { bless {}, shift }; sub AUTOLOAD { print "AUTOLOAD: @_ : $AUTOLOAD\n"; my $self = shift; die "'$self' is not an object\n" unless ref($self); print "Doing some AUTOLOAD'ing magic\n"; } sub DESTROY {} sub frobnitz { my $foo = new Foo ( input => { } ); } package Foo; sub new { bless {}, shift }; package main; my $bar = Bar->new; $bar->frobnitz;