__PACKAGE__ does what you expect here, but I doubt that you can subclass from the code.
Using of __PACKAGE__ makes subclass from this class most of the time impossible. Propably this is not what you do.
yy is the subclass and the expected output should be YYYY but you get XXYY since the package is hardcoded.
package xx;
sub new { bless {}, shift }
sub instance { __PACKAGE__->new }
sub print { print "XX" }
package yy;
@ISA = qw/xx/;
sub print { print "YY" }
package main;
my $yy = yy->instance;
$yy->print;
my $yyy = yy->new;
$yyy->print