in reply to STDIN and STDOUT as a single filehandle?
update: Here is a start
package ReadOneWriteOtherone; use strict; use warnings; sub TIEHANDLE { my( $self, $in, $out ) = @_; $self = bless { in => $in, out => $out}, $self; return $self; } sub PRINT { my $self = shift; $self = $self->{out}; print $self @_; } sub READLINE { my $self = shift; $self = $self->{in}; readline $self; } sub CLOSE { my $self = shift; close $self->{in}; close $self->{out}; } 1; package main; unless( caller ){ tie *BLOG => ReadOneWriteOtherone => \*STDIN, \*STDOUT or die "Cou +ldn't tie BLOG : $!"; print tied(*BLOG),$/; print tied(*BLOG)->{in},$/; print tied(*BLOG)->{out},$/; print "Enter some input buddy and hit enter : $/"; print BLOG "You entered: ", scalar <BLOG>; } __END__ $$ perl ReadOneWriteOtherone.pm ReadOneWriteOtherone=HASH(0x1abf1a4) GLOB(0x1ab7f34) GLOB(0x1ab5054) Enter some input buddy and hit enter : Hi there You entered: Hi there
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: STDIN and STDOUT as a single filehandle?
by scottb (Scribe) on May 31, 2004 at 19:44 UTC | |
by gmpassos (Priest) on Jun 01, 2004 at 06:09 UTC |