#!/usr/bin/perl package Foo; sub new { # ... } # other stuff if (!caller()) { my $foo = new Foo; # test foo's methods, etc } 1;