#!/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