format to scalar better solution?
1 answers - 669 bytes -

Hello all,
I like format function, but I miss output to scalars.
write always print to STDUT, or filehandle, but I need access
contents to scalar. I found in docs one solution, but it is not much
nice:
use Carp;
sub swrite {
croak "usage: swrite PICTURE ARGS" unless @_;
my $format = shift;
$^A = "";
formline($format,@_);
return $^A;
}
$string = swrite(<<'END', 1, 2, 3);
Check me out
@<<< @||| @
END
print $string;
but when I have in formating template lets say 40 variables
I'm just curious, if there are some other possibilities.
Thanks
/brano