<?xml version="1.0" encoding="windows-1252"?>
<node id="882854" title="Re^3: writing report using format" created="2011-01-18 06:41:54" updated="2011-01-18 06:41:54">
<type id="11">
note</type>
<author id="764402">
stefbv</author>
<data>
<field name="doctext">
&lt;p&gt;Here is an example you might find useful:&lt;/p&gt;
&lt;c&gt;
use strict;
use warnings;

# Formats

my ($crt, $text, $num);
format =
  @&lt;  @&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;  @###.##
  $crt, $text, $num
.

format STDOUT_TOP =
  @|||||||||||||||||||||
  "Example Format"
  ----------------------
  Nr  Text      Number
  --  --------  --------
.

my $total = 0;
format RAPORT_TOTAL =
  ----------------------
                 @###.##
                 $total
  ----------------------
.

# End formats

while (&lt;DATA&gt;) {
    s /[\n|\r]//g; # clean
    ($crt, $text, $num) = split(/;/, $_, 3);
    $total += $num;
    write();
}

# Change format
$~ = "RAPORT_TOTAL";
write();

__DATA__
1;some data;123.34
2;other;432.54
3;testing;123.55
&lt;/c&gt;
&lt;p&gt;Regards, Stefan&lt;/p&gt;</field>
<field name="root_node">
882809</field>
<field name="parent_node">
882840</field>
</data>
</node>
