6 unless (find PerlIO::Layer 'perlio') {
7 print "1..0 # Skip: not perlio\n";
17 open($fh,"+<",\$var) or print "not ";
20 print "not " unless eof($fh);
22 seek($fh,0,0) or print "not ";
23 print "not " if eof($fh);
26 print $fh "ok 7\n" or print "not ";
30 seek($fh,0,0) or print "not ";
31 print "not " if eof($fh);
33 print "not " unless <$fh> eq "foo\n";
37 print "# Close on scalar failed: $!\n";
42 # Test that semantics are similar to normal file-based I/O
43 # Check that ">" clobbers the scalar
46 print "# Got [$var], expect []\n";
47 print "not " unless $var eq "";
49 # Check that file offset set to beginning of scalar
51 print "# Got $off, expect 0\n";
52 print "not " unless $off == 0;
54 # Check that writes go where they should and update the offset
58 print "# Got $off, expect 4\n";
59 print "not " unless $off == 4;
61 print "# Got [$var], expect [Breathing]\n";
62 print "not " unless $var eq "Breathing";
66 # Check that ">>" appends to the scalar
68 open $fh, ">>", \$var;
70 print "# Got $off, expect 10\n";
71 print "not " unless $off == 10;
73 print "# Got [$var], expect [Something ]\n";
74 print "not " unless $var eq "Something ";
76 # Check that further writes go to the very end of the scalar
78 print "# Got [$var], expect [Something else ]\n";
79 print "not " unless $var eq "Something else ";
82 print "# Got $off, expect 10\n";
83 print "not " unless $off == 10;
86 print "# Got [$var], expect [Something else is here]\n";
87 print "not " unless $var eq "Something else is here";
91 # Check that updates to the scalar from elsewhere do not
93 $var = "line one\nline two\line three\n";
99 print "# Got [$var], expect [foo]\n";
100 print "not " unless $var eq "foo";
103 # Check that dup'ing the handle works
107 open $fh, "+>", \$var;
110 print $dup "ok 22\n";