package Foo; use warnings; use strict; use Exporter qw(import); our @EXPORT_OK = qw(function_or_method); our %EXPORT_TAGS = (all => [@EXPORT_OK]); sub new { return bless {}, shift; } sub function_or_method { # Throw away the first param if: # A) it's defined, and # B) it's either the class, or an object of the class if (defined $_[0]) { shift if $_[0] eq __PACKAGE__ || ref $_[0] eq __PACKAGE__; } # Now we grab the remaining params (if expecting any) my ($call_num, $call_type) = @_; print "Num: $call_num called as $call_type\n"; }