use warnings; use strict; package Obj; use Exporter qw(import); our @EXPORT_OK = qw(foo); sub new { return bless {}, shift; } sub foo { my $self; if ($_[0] eq __PACKAGE__ || ref $_[0] eq __PACKAGE__){ $self = shift; } my ($x, $y) = @_; return $x * $y; }