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