Multiline fields : Field « Report « Perl






Multiline fields

   

#!/usr/bin/perl

use warnings;
use strict;

my $name = 'Tom';
my $letters = 'AAA';
my $phone = '(111)111-1111';
my $itemA = <<'DONE';
Line 1 
Line 2. 
DONE
write();

$name = 'Jack';
$letters = 'AAA';
$phone = '(222)222-2222';
$itemA = <<'DONE';
Line 3
Line 4
Line 5
DONE
write();

$name = 'Mary';
$letters = 'CCC';
$phone = '';
$itemA = 'my item.';
write();

format STDOUT =
Name: @<<<<<<<<<<<<<<<<<<<  itemA:   ^<<<<<<<<<<<<<<<<<<<<<
      $name,                           $itemA 
letters: @<<<<<                        ^<<<<<<<<<<<<<<<<<<<<<<<<
        $letters,                      $itemA
phone: @||||||||||||                   ^<<<<<<<<<<<<<<<<<<<<<<<<~
       $phone,                         $itemA
~                                      ^<<<<<<<<<<<<<<<<<<<<<<<<
                                       $itemA
~                                      ^<<<<<<<<<<<<<<<<<<<<<<<<
                                       $itemA
~                                      ^<<<<<<<<<<<<<<<<<<<<<...
                                       $itemA
                                         
.

   
    
    
  








Related examples in the same category

1.Format Field Types
2.Split a long field over multiple lines
3.Field Designator Symbols
4.Field Display Symbols
5.Different types of fields
6.Writes a string using the multiline field format.
7.Using value fields to print output.
8.Valid value-field formats.
9.Limitations of the @* value field.
10.A program that uses a value field that does formatting.