Here is a short example using formline and the accumulator based on your code. I simplified the INHALT format because I wasn't fully sure what you wanted to do with the ~~:
#!/usr/bin/perl -w use strict; # Store the formats in variables my $header = << 'HEADER'; Menge Art.nr. Bezeichnung Preis(?) Gesamt(?) __________________________________________________________________ +___ HEADER my $body = << 'INHALT'; @<<<< ^<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>> @>>>>>>>>> INHALT my $footer = << 'FOOTER'; __________________________________________________________________ +___ Warenwert: @>>>>>>>>> FOOTER # Sample data my @bestellung = ('Text one|1|3.99|7', 'Text two|2|5.49|8', 'Text three|3|7.89|9'); formline($header); foreach (@bestellung) { my ($text, $nr, $preis, $menge) = split /\|/; my $summe = sprintf("%.2f", $menge*$preis); formline($body, $menge,$nr,$text,$preis,$summe); } formline($footer, 1234); print $^A; # Print the accumulator $^A = ''; # Clear the accumulator __END__ prints: Menge Art.nr. Bezeichnung Preis(?) Gesamt(?) __________________________________________________________________ +___ 7 1 Text one 3.99 27.93 8 2 Text two 5.49 43.92 9 3 Text three 7.89 71.01 __________________________________________________________________ +___ Warenwert: 1234

See also Re: Formats and Variable Scope and Re: format and IO::String.

--
John.


In reply to Re: How to route a format into a variable by jmcnamara
in thread How to route a format into a variable by ppm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.