in reply to redirecting STDOUT output to variable?

The first question is how to open a scalar for I/O write?
#!/usr/bin/perl -w use strict; my $output; open (OUT, ">", \$output) or die "can't open scalar for out"; print OUT "this is some line\n"; print OUT "this is another line\n"; print "printing the output variable:\n"; print $output; __END__ OUTPUT..... printing the output variable: this is some line this is another line
I think you can also open STDOUT like above. Of course then you have to do something else to test rather just print!

Update:Saw Ikegami's code after I posted. That looks great also. I didn't quite understand the context of why you want to do this?