#!/usr/bin/perl -w use strict; use IO::Scalar; my $str; tie *STDOUT, 'IO::Scalar', \$str; print "hello, world"; untie *STDOUT; print "The data is here: ",$str;