in reply to Re^4: Virtual Filehandles..
in thread Virtual Filehandles..

I didn't know it used a temp file. If I were to build the module to do this I'd use Tie::Handle and overload the writing functions.

I didn't test this or even try to compile it.

my $data = tie $fh, 'Tie::Handle::Scalar::WithoutTemp'; print $fh "Hello world"; print $$data; package Tie::Handle::Scalar::WithoutTemp; use base 'Tie::Handle'; sub TIEHANDLE { my $classname = shift; my $data; bless \ $data, $classname; } sub WRITE { my ( $self, $scalar, $length, $offset ) = @_; $$data .= substr $scalar, $offset, $length; 1; } sub PRINT { $$data .= join $,, @_[ 1 .. $#_ ]; 1; } sub PRINTF { $$data .= sprintf $_[1], @_[ 2 .. $#_ ]; 1; }