restructure file locations
[perl/plp/.git] / lib / PLP / Tie / Print.pm
diff --git a/lib/PLP/Tie/Print.pm b/lib/PLP/Tie/Print.pm
new file mode 100644 (file)
index 0000000..ef537a0
--- /dev/null
@@ -0,0 +1,48 @@
+package PLP::Tie::Print;
+
+use strict;
+
+=head1 PLP::Tie::Print
+
+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 { bless \my $dummy, $_[0] }
+
+sub WRITE { undef }
+
+sub PRINT {
+       shift;
+       return unless grep length, @_;
+       PLP::sendheaders() unless $PLP::sentheaders;
+       print STDOUT @_;
+       select STDOUT;
+}
+
+sub PRINTF {
+       shift;
+       return unless length $_[0];
+       PLP::sendheaders() unless $PLP::sentheaders;
+       printf STDOUT @_;
+       select STDOUT;
+}
+
+sub READ { undef }
+
+sub READLINE { undef }
+
+sub GETC { '%' }
+
+sub CLOSE { undef }
+
+sub UNTIE { undef }
+
+sub DESTROY { undef }
+
+1;
+