package PKG; sub safe_sub { # The next line contains the purpose of my post... shift if ref $_[0] or $_[0] =~ /^PKG/; # The below is just to make sure it's working (or not working :) my ($hash, $string) = @_; print "$hash->{foo}\n$string"; } sub new { bless {}, shift; }