From: Gisle Aas Date: Mon, 4 Sep 2000 00:04:22 +0000 (+0000) Subject: Tie::StdHandle did not know about 3-arg open X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=052b629eb0274721d73944a03d3c4aac89392a61;p=p5sagit%2Fp5-mst-13.2.git Tie::StdHandle did not know about 3-arg open Message-ID: <20000904000422.26002.qmail@eik.g.aas.no> p4raw-id: //depot/perl@7022 --- diff --git a/lib/Tie/Handle.pm b/lib/Tie/Handle.pm index 42d0834..86adad2 100644 --- a/lib/Tie/Handle.pm +++ b/lib/Tie/Handle.pm @@ -183,10 +183,10 @@ sub WRITE { sub CLOSE { my $pkg = ref $_[0]; croak "$pkg doesn't define a CLOSE method"; -} +} package Tie::StdHandle; -our @ISA = 'Tie::Handle'; +our @ISA = 'Tie::Handle'; use Carp; sub TIEHANDLE @@ -196,7 +196,7 @@ sub TIEHANDLE bless $fh,$class; $fh->OPEN(@_) if (@_); return $fh; -} +} sub EOF { eof($_[0]) } sub TELL { tell($_[0]) } @@ -206,9 +206,9 @@ sub CLOSE { close($_[0]) } sub BINMODE { binmode($_[0]) } sub OPEN -{ +{ $_[0]->CLOSE if defined($_[0]->FILENO); - open($_[0],$_[1]); + @_ == 2 ? open($_[0], $_[1]) : open($_[0], $_[1], $_[2]); } sub READ { read($_[0],$_[1],$_[2]) } @@ -216,7 +216,7 @@ sub READLINE { my $fh = $_[0]; <$fh> } sub GETC { getc($_[0]) } sub WRITE -{ +{ my $fh = $_[0]; print $fh substr($_[1],0,$_[2]) } diff --git a/t/lib/tie-stdhandle.t b/t/lib/tie-stdhandle.t index d1f9a81..f03f5d9 100755 --- a/t/lib/tie-stdhandle.t +++ b/t/lib/tie-stdhandle.t @@ -10,16 +10,16 @@ tie *tst,Tie::StdHandle; $f = 'tst'; -print "1..13\n"; +print "1..13\n"; # my $file tests -unlink("afile.new") if -f "afile"; -print "$!\nnot " unless open($f,"+>afile"); +unlink("afile.new") if -f "afile"; +print "$!\nnot " unless open($f,"+>afile") && open($f, "+<", "afile"); print "ok 1\n"; print "$!\nnot " unless binmode($f); print "ok 2\n"; -print "not " unless -f "afile"; +print "not " unless -f "afile"; print "ok 3\n"; print "not " unless print $f "SomeData\n"; print "ok 4\n"; @@ -44,4 +44,4 @@ print "not " unless eof($f); print "ok 12\n"; print "not " unless close($f); print "ok 13\n"; -unlink("afile"); +unlink("afile");