#!/usr/local/bin/perl
#
# Open a file create/write
# Print out a simple formatted report
#
$col_1="column one text 789_12345" ;
$col_2="column two text 789_12345" ;
$col_3=123456789.12345 ;
$note_1 = "Note 1: The code segment demonstrates the method of generating a formatted report using several variables containing text and numbers. " ;
$note_2 = "Note 2: The code segment demonstrates the method of generating a formatted report using several variables containing text and numbers. " ;
$note_3 = "Note 3: The code segment demonstrates \n the method of generating a \n formatted report using several \n variables containing text \n and numbers. " ;
open ( REPORT_FILE, ">report.txt" ) || die " report.txt $! \n " ;
# a dot marks the end of the format
format REPORT_FILE =
123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456
+--------------------------------------------------------------------------+
| Top of Report |
+--------------------------------------------------------------------------+
|Column One |Column Two |Column Three |
+------------------------+------------------------+------------------------+
| | | |
| @<<<<<<<<<<<<<<<<<<<<< | @<<<<<<<<<<<<<<<<<<<<< | @##################.## |
$col_1, $col_2, $col_3
| @<<<<<<<<<<<<<<<<<<<<< | @<<<<<<<<<<<<<<<<<<<<< | @##################.## |
$col_1, $col_2, $col_3
| @<<<<<<<<<<<<<<<<<<<<< | @<<<<<<<<<<<<<<<<<<<<< | @##################.## |
$col_1, $col_2, $col_3
| | | |
+------------------------+------------------------+------------------------+
^|||||||||||||||||||||||||||||||||||||||
$note_1
~ ^|||||||||||||||||||||||||||||||||||||||
$note_1
~ ^|||||||||||||||||||||||||||||||||||||||
$note_1
~ ^|||||||||||||||||||||||||||||||||||||||
$note_1
~ ^|||||||||||||||||||||||||||||||||||||||
$note_1
~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$note_2
@*
$note_3
+--------------------------------------------------------------------------+
.
# make sure the dot is in column one
write REPORT_FILE ;
print "\n\nALL DONE\n\n" ;
#
# DONE
#
Wednesday, January 12, 2011
Simple Report Formats
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment