use IO::Scalar; $data = join '', ; my $s; tie *STDIN, 'IO::Scalar', \$s; print STDIN $data; tied(*STDIN)->setpos(0);