#! perl -sw use strict; sub immutable { print "immutable received args: [ @_ ]\n"; print "Some more stuff\n"; } ## Save a copy of STDOUT open SAVED, '>&=STDOUT'; close STDOUT; ## Open STDOUT to a variable (ramfile)(Requires 5.8.x) open STDOUT, '>', \ my( $var ) or die $!; ## Call the sub immutable( qw[ some args here ] ); ## Close the ramfile close STDOUT; ## Redirect STDOUT back to it's original place open STDOUT, '>&=SAVED' or die $!; ## Discard the backup close SAVED; ## Use the captured output print "The variable \$var now contains:\n'$var'\n"; __END__ C:\test>junk2 The variable $var now contains: 'immutable received args: [ some args here ] Some more stuff '