#!/usr/bin/perl
use strict;
use warnings;
my ($date, $reference, $rep_line);
my $format = q/format REP_TOP =
@<<<<<<<<<<<<<<< @>>>>>>>>>>>>>>
$date, $reference
.
/;
eval $format;
$format = q/format REP =
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$rep_line
.
/;
eval $format;
$date = "11/11/2011";
$reference = "REF123";
open my $fh, ">", "/tmp/test.txt" or die "$!\n";
$fh->format_name("REP");
$fh->format_top_name("REP_TOP");
$fh->autoflush(1);
$fh->format_lines_per_page(10);
for (@ARGV) {
$rep_line = $_;
write $fh;
}
####
$ perl testformat.pl 0 1 " " 2 3 " " 4 5;
$ cat /tmp/test.txt
11/11/2011 REF123
0
1
2
3
4
5
####
$ perl testformat.pl 0 1 " " 2 3 " " 4 5;
$ cat /tmp/test.txt
11/11/2011 REF123
0
1
2
3
4
5