Since we still want "our $_" to be always forced to $main::_,
deplace the forcing code at our-pad allocation time.
(Making execution probably a tiny bit faster)
p4raw-id: //depot/perl@23608
}
len = namend - name;
- /* $_ should always be in main:: even when our'ed */
- if (*name == '_' && !name[1])
- stash = PL_defstash;
-
/* No stash in name, so see how we can default */
if (!stash) {
off = pad_add_name(name,
PL_in_my_stash,
(PL_in_my == KEY_our
- ? (PL_curstash ? PL_curstash : PL_defstash)
+ /* $_ is always in main::, even with our */
+ ? (PL_curstash && !strEQ(name,"$_") ? PL_curstash : PL_defstash)
: Nullhv
),
0 /* not fake */
@INC = '../lib';
}
-print "1..66\n";
+print "1..70\n";
my $test = 0;
sub ok ($$) {
ok( $x eq "hello\n", 'reading from <$_> works' );
close $_;
}
+
+{
+ $fqdb::_ = 'fqdb';
+ ok( $fqdb::_ eq 'fqdb', 'fully qualified $_ is not in main' );
+ ok( eval q/$fqdb::_/ eq 'fqdb', 'fully qualified, evaled $_ is not in main' );
+ package fqdb;
+ ::ok( $_ ne 'fqdb', 'unqualified $_ is in main' );
+ ::ok( q/$_/ ne 'fqdb', 'unqualified, evaled $_ is in main' );
+}