readline() doesn't work with our variables; it confuses them with
my variables (change#4227 was incomplete)
p4raw-link: @12549 on //depot/maint-5.6/perl:
5e948b4e169e88676c1f1359a0a62d670c4b4221
p4raw-link: @4227 on //depot/perl:
77ca0c92d2c0e47301d906d355d9ab3afb6f6bcb
p4raw-id: //depot/perl@12561
p4raw-integrated: from //depot/maint-5.6/perl@12558 'copy in'
t/base/rs.t (@8152..) 'edit in' toke.c (@12549..)
#!./perl
# Test $!
-print "1..14\n";
+print "1..16\n";
$teststring = "1\n12\n123\n1234\n1234\n12345\n\n123456\n1234567\n";
$bar = <TESTFILE>;
if ($bar eq "78") {print "ok 10\n";} else {print "not ok 10\n";}
-# Get rid of the temp file
close TESTFILE;
-unlink "./foo";
# Now for the tricky bit--full record reading
if ($^O eq 'VMS') {
# put their own tests in) so we just punt
foreach $test (11..14) {print "ok $test # skipped on non-VMS system\n"};
}
+
+$/ = "\n";
+
+# see if open/readline/close work on our and my variables
+{
+ if (open our $T, "./foo") {
+ my $line = <$T>;
+ print "# $line\n";
+ length($line) == 40 or print "not ";
+ close $T or print "not ";
+ }
+ else {
+ print "not ";
+ }
+ print "ok 15\n";
+}
+
+{
+ if (open my $T, "./foo") {
+ my $line = <$T>;
+ print "# $line\n";
+ length($line) == 40 or print "not ";
+ close $T or print "not ";
+ }
+ else {
+ print "not ";
+ }
+ print "ok 16\n";
+}
+
+# Get rid of the temp file
+END { unlink "./foo"; }
Name "Foo::foo" used only once: possible typo at - line 11.
########
+--FILE-- abc
+ok
+--FILE--
+# check if our variables are introduced correctly in readline()
+package Foo;
+use strict 'vars';
+our $FH;
+open $FH, "abc" or die "Can't open 'abc': $!";
+print <$FH>;
+close $FH;
+EXPECT
+ok
+########
+
# Make sure the strict vars failure still occurs
# now that the `@i should be written as \@i' failure does not occur
# 20000522 mjd@plover.com (MJD)
add symbol table ops
*/
if ((tmp = pad_findmy(d)) != NOT_IN_PAD) {
- OP *o = newOP(OP_PADSV, 0);
- o->op_targ = tmp;
- PL_lex_op = (OP*)newUNOP(OP_READLINE, 0, o);
+ SV *namesv = AvARRAY(PL_comppad_name)[tmp];
+ if (SvFLAGS(namesv) & SVpad_OUR) {
+ SV *sym = sv_2mortal(newSVpv(HvNAME(GvSTASH(namesv)),0));
+ sv_catpvn(sym, "::", 2);
+ sv_catpv(sym, d+1);
+ d = SvPVX(sym);
+ goto intro_sym;
+ }
+ else {
+ OP *o = newOP(OP_PADSV, 0);
+ o->op_targ = tmp;
+ PL_lex_op = (OP*)newUNOP(OP_READLINE, 0, o);
+ }
}
else {
- GV *gv = gv_fetchpv(d+1,TRUE, SVt_PV);
+ GV *gv;
+ ++d;
+intro_sym:
+ gv = gv_fetchpv(d,
+ (PL_in_eval
+ ? (GV_ADDMULTI | GV_ADDINEVAL)
+ : TRUE),
+ SVt_PV);
PL_lex_op = (OP*)newUNOP(OP_READLINE, 0,
newUNOP(OP_RV2SV, 0,
newGVOP(OP_GV, 0, gv)));