in reply to perl 5.32 format question
G'day hotpelmen,
The oldest version I have is v5.30.0, so I couldn't attempt to replicate your results. I had a look in perlform for a number of versions but couldn't find any change. My look was brief; you may want to study more closely:
I suspect you may be right about '~' & '~~'. There does seem to be some conflict between "perlform: Suppressing Lines Where All Fields Are Void" and "perlform: Repeating Format Lines".
"Assuming I still want to use format, how would you advise to overcome this and achieve printing of whitespace values into separate lines of report?"
This code, pm_11152452_testformat.pl, worked for me.
#!/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;
I kept REP_LINE_MAX_LENGTH very short for demo purposes; you'll want it to be 33 (if I counted correctly). I tested it on three versions:
$ ./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
See how you go with 5.16.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl 5.32 format question
by hotpelmen (Scribe) on May 30, 2023 at 16:23 UTC |