SV **sp = &sv; /* Used in tryAMAGICunDEREF macro. */
tryAMAGICunDEREF(to_cv);
- cv = (CV*)SvRV(sv);
- if (SvTYPE(cv) != SVt_PVCV)
+ sv = SvRV(sv);
+ if (SvTYPE(sv) == SVt_PVCV) {
+ cv = (CV*)sv;
+ *gvp = Nullgv;
+ *st = CvSTASH(cv);
+ return cv;
+ }
+ else if(isGV(sv))
+ gv = (GV*)sv;
+ else
croak("Not a subroutine reference");
- *gvp = Nullgv;
- *st = CvSTASH(cv);
- return cv;
}
- if (isGV(sv))
+ else if (isGV(sv))
gv = (GV*)sv;
else
gv = gv_fetchpv(SvPV(sv, PL_na), lref, SVt_PVCV);
#!./perl
-print "1..27\n";
+print "1..29\n";
sub backwards { $a lt $b ? 1 : $a gt $b ? -1 : 0 }
{
my $sortsub = \&backwards;
my $sortglob = *backwards;
+ my $sortglobr = \*backwards;
my $sortname = 'backwards';
@b = sort $sortsub 4,1,3,2;
print ("@b" eq '4 3 2 1' ? "ok 22\n" : "not ok 22 |@b|\n");
print ("@b" eq '4 3 2 1' ? "ok 23\n" : "not ok 23 |@b|\n");
@b = sort $sortname 4,1,3,2;
print ("@b" eq '4 3 2 1' ? "ok 24\n" : "not ok 24 |@b|\n");
+ @b = sort $sortglobr 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 25\n" : "not ok 25 |@b|\n");
}
{
local $sortsub = \&backwards;
local $sortglob = *backwards;
+ local $sortglobr = \*backwards;
local $sortname = 'backwards';
@b = sort $sortsub 4,1,3,2;
- print ("@b" eq '4 3 2 1' ? "ok 25\n" : "not ok 22 |@b|\n");
+ print ("@b" eq '4 3 2 1' ? "ok 26\n" : "not ok 26 |@b|\n");
@b = sort $sortglob 4,1,3,2;
- print ("@b" eq '4 3 2 1' ? "ok 26\n" : "not ok 23 |@b|\n");
+ print ("@b" eq '4 3 2 1' ? "ok 27\n" : "not ok 27 |@b|\n");
@b = sort $sortname 4,1,3,2;
- print ("@b" eq '4 3 2 1' ? "ok 27\n" : "not ok 24 |@b|\n");
+ print ("@b" eq '4 3 2 1' ? "ok 28\n" : "not ok 28 |@b|\n");
+ @b = sort $sortglobr 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 29\n" : "not ok 29 |@b|\n");
}