#!/usr/bin/env perl use strict; use warnings; use autodie; use constant REP_LINE_MAX_LENGTH => 3; # For demo only print "Perl version: $^V\n"; my $outfile = '/tmp/pm_11152452_test.txt'; my ($date, $reference, $rep_line); format REP_TOP = @<<<<<<<<<<<<<<< @>>>>>>>>>>>>>> $date, $reference . format REP = ^*~~ $rep_line . $date = '11/11/2011'; $reference = 'REF123'; open my $fh, '>', $outfile; $fh->format_name('REP'); $fh->format_top_name('REP_TOP'); $fh->autoflush(1); $fh->format_lines_per_page(10); for (@ARGV) { $rep_line = substr($_, 0, REP_LINE_MAX_LENGTH); write $fh; } # For demo only system cat => $outfile; unlink $outfile; #### $ ./pm_11152452_testformat.pl zero one " " two three " " four five Perl version: v5.30.0 11/11/2011 REF123 zer one two thr fou fiv $ ./pm_11152452_testformat.pl zero one " " two three " " four five Perl version: v5.32.0 11/11/2011 REF123 zer one two thr fou fiv $ ./pm_11152452_testformat.pl zero one " " two three " " four five Perl version: v5.36.0 11/11/2011 REF123 zer one two thr fou fiv