http://www.perlmonks.org?node_id=593051


in reply to How do I print formatted text to a scalar instead of a filehandle?

Writing to a scalar is a pretty good way to do it:

use strict; use warnings; my %hash = (one => 1, two => 2, three => 3); # create a format picture for use with formline format OUTPUT = @<<<<<<<<< @## $_, $hash{$_} . my $str; open OUTPUT, '>', \$str; write OUTPUT foreach sort keys %hash; close OUTPUT; print $str;