Understanding Formats : Format « Report « Perl






Understanding Formats

   

A format defines how data will appear. 
The format command defines a format. 
The basic syntax follows: 

format NAME = formatdata

The format definition ends with a single period on its own on a line. 
The format data come in pairs of lines. 
In each pair, the first line, called the picture line, lists how the data will look; 
the second line, called the argument line, lists the global Perl variables that will hold the data. 
When the report is generated, the data values get plugged into the picture lines.

For example,

format NAMES=
Last name : @<<<<<<<<<<<<<<<<<<<<
$lastname
First name: @<<<<<<<<<<<
$firstname

.


The @<<<<<<<<<<< format defines a left-justified data field. 
The number of < characters defines how many spaces are allotted for the field. The lines with variables, $lastname and $firstname, aren't printed. 
Only the lines that define the format are printed.

   
    
    
  








Related examples in the same category

1.A program that uses a print format.
2.A simple format example
3.Define format and variables for the format
4.Perl stores page number in the $% variable.
5.Report field pictures
6.Uses the select function.
7.Using format to save data to a file
8.^ fieldholder creates a filled paragraph