package My::Package::Version; use strict; use vars qw(@ISA @EXPORT $VERSION); use Exporter; @ISA = qw(Exporter); @EXPORT = qw($VERSION); $VERSION = 3.14; sub import { my $i = 0; my $pkg = caller(0); print "Import Caller Trace:\n"; while($pkg) { print " Called from package $pkg\n"; # Note that these tests have been moved from the # loop condition to inside the loop so the loop # will not terminate if it fails. if($pkg =~ /^My::Package::/ and not defined ${"$pkg\::VERSION"}) { print " (Exporting VERSION to $pkg)\n"; __PACKAGE__->export_to_level($i+1); } $pkg = caller(++$i); } }