- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

17.11.2 Accessing Formatting Internals

For low-level access to the formatting mechanism. you may use formline() and access $^A (the $ACCUMULATOR variable) directly.

For example:

$str = formline <<'END', 1,2,3;
@<<<  @|||  @>>>
print "Wow, I just stored `$^A' in the accumulator!\n";

Or to make an swrite() subroutine, which is to write() what sprintf() is to printf(), do this:

   use Carp;
   sub swrite {
       croak "usage: swrite PICTURE ARGS" unless @_;
       my $format = shift;
       $^A = "";
       return $^A;
   $string = swrite(<<'END', 1, 2, 3);
Check me out
@<<<  @|||  @>>>
   print $string;
ISBN 9781906966027Perl Language Reference ManualSee the print edition