Provide 'tie' capability with 'My::Web' classname for output &Wprint.
authorshort <>
Sat, 30 Oct 2004 16:24:27 +0000 (16:24 +0000)
committershort <>
Sat, 30 Oct 2004 16:24:27 +0000 (16:24 +0000)
Web.pm

diff --git a/Web.pm b/Web.pm
index 2dd7747..ea9b928 100644 (file)
--- a/Web.pm
+++ b/Web.pm
@@ -28,7 +28,7 @@ sub Wrequire ($);
 sub Wuse ($@);
 our $W;
 our @EXPORT=qw(&Wrequire &Wuse &a_href &a_href_cz &vskip &img &centerimg &rightimg $W &top_dir &top_dir_disk &Wprint);
 sub Wuse ($@);
 our $W;
 our @EXPORT=qw(&Wrequire &Wuse &a_href &a_href_cz &vskip &img &centerimg &rightimg $W &top_dir &top_dir_disk &Wprint);
-our @ISA=qw(Exporter);
+our @ISA=qw(Exporter Tie::Handle);
 
 BEGIN
 {
 
 BEGIN
 {
@@ -76,6 +76,7 @@ require HTTP::Negotiate;
 my $have_Geo_IP; BEGIN { $have_Geo_IP=eval { require Geo::IP; 1; }; }
 use ModPerl::Util qw(exit);
 use POSIX qw(strftime);
 my $have_Geo_IP; BEGIN { $have_Geo_IP=eval { require Geo::IP; 1; }; }
 use ModPerl::Util qw(exit);
 use POSIX qw(strftime);
+use Tie::Handle;
 
 
 #our $W;
 
 
 #our $W;
@@ -171,14 +172,32 @@ my($class,%args)=@_;
 
        $ENV{"HOSTNAME"}||=&{$W->{"web_hostname_sub"}}();
 
 
        $ENV{"HOSTNAME"}||=&{$W->{"web_hostname_sub"}}();
 
-       return $W;
+       return bless $W,$class;
 }
 
 sub Wprint($)
 {
 my($text)=@_;
 
 }
 
 sub Wprint($)
 {
 my($text)=@_;
 
-       $W->{"r"}->print($text);
+       $W->{"r"}->puts($text);
+}
+
+# local *FH;
+# tie *FH,ref($W),$W;
+sub TIEHANDLE($)
+{
+my($class,$W)=@_;
+
+       my $self={};
+       $self->{"W"}=$W or confess "Missing W";
+       return bless $self,$class;
+}
+
+sub WRITE
+{
+my($self,$scalar,$length,$offset)=@_;
+
+       Wprint substr($scalar,0,$length);
 }
 
 sub top_dir_disk ()
 }
 
 sub top_dir_disk ()