in reply to How to route a format into a variable
#!/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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How to route a format into a variable
by ppm (Novice) on Feb 12, 2003 at 18:52 UTC | |
|
Re: Re: How to route a format into a variable
by ppm (Novice) on Feb 13, 2003 at 20:55 UTC |