fix header sending for tied printing
[perl/plp/.git] / PLP / Tie / Print.pm
index 0647f7c10826200f1ab2e3f6aed81f4b9387ac0f..83b5c76726f7b41f30dd4411634e973b5b5c2521 100644 (file)
@@ -1,6 +1,5 @@
-#--------------------#
- package PLP::Tie::Print;
-#--------------------#
+package PLP::Tie::Print;
+
 use strict;
 
 =head1 PLP::Tie::Print
@@ -9,25 +8,27 @@ Just prints to stdout, but sends headers if not sent before.
 
     tie *HANDLE, 'PLP::Tie::Print';
 
+This module is part of the PLP Internals and probably not of much use to others.
+
 =cut
 
-sub TIEHANDLE {
-    return bless {}, $_[0];
-}
+sub TIEHANDLE { bless \my $dummy, $_[0] }
 
-sub WRITE { undef; }
+sub WRITE { undef }
 
 sub PRINT {
-    my ($self, @param) = @_;
-    return if @param == 1 and not length $param[0];
+    shift;
+    return unless grep length, @_;
     PLP::sendheaders() unless $PLP::sentheaders;
-    print STDOUT @param;
+    print STDOUT @_;
     select STDOUT;
 }
 
 sub PRINTF {
-    my ($self, @param) = @_;
-    printf STDOUT @param;
+    shift;
+    return unless length $_[0];
+    PLP::sendheaders() unless $PLP::sentheaders;
+    printf STDOUT @_;
     select STDOUT;
 }
 
@@ -41,5 +42,7 @@ sub CLOSE { undef }
 
 sub UNTIE { undef }
 
+sub DESTROY { undef }
+
 1;