#! perl -w
use strict;
undef $/; #get all textlines as one unit
my $data = <DATA>;
# then for each line (set of 6 items that you parsed) call the LINE function
while ( $data =~ /\W*(\w+)\W+(\w+)\W+(\w+)\W+(\w+)\W+(\w+)\W+(\w+)/g ) {
write;
}
print "\n\t\t\tEnd of report\n";
format STDOUT_TOP =
Whatever header text you may desire
@| || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || |
scalar localtime()
Item 1 Item 2 Item 3 Item 4 Item 5 Item 6
---------- ---------- ---------- ---------- ---------- ----------
.
format STDOUT =
@<<<<<<<<< @<<<<<<<<< @<<<<<<<<< @<<<<<<<<< @<<<<<<<<< @<<<<<<<<<
$1, $2, $3, $4, $5, $6
.
__END__
This page describes the syntax of regular expressions in Perl.
For a description of how to use regular expressions in matching
operations, plus various examples of the same, see discussions of m//,
s///, qr// and ?? in Regexp Quote-Like Operators in the perlop
manpage.
Matching operations can have various modifiers. Modifiers that relate
to the interpretation of the regular expression inside are listed
below. Modifiers that alter the way a regular expression is used by
Perl are detailed in Regexp Quote-Like Operators in the perlop manpage
and Gory details of parsing quoted constructs in the perlop manpage.
{/CODE}
All you need (besides the formats) is to prepare your 6 item variables and do a write. Formatting, page skips etcetera are handle fully transparantly. See the perlform manpage.
When you run this little script, you get this nicely fromatted output:
Whatever header text you may desire
Fri Apr 28 21:35:19 2000
Item 1 Item 2 Item 3 Item 4 Item 5 Item 6
---------- ---------- ---------- ---------- ---------- ----------
This page describes the syntax of
regular expression in Perl For a
descriptio of how to use regular
expression in matching operations plus various
examples of the same see discussion
of m s qr and in
Regexp Quote Like Operators in the
perlop manpage Matching operations can have
various modifiers Modifiers that relate to
the interpreta of the regular expression
inside are listed below Modifiers that
alter the way a regular expression
is used by Perl are detailed
in Regexp Quote Like Operators in
the perlop manpage and Gory details
of parsing quoted constructs in the
End of report
[?CODE]
pp2u
(-: Perl Power to You :-)
(Comment added after I saw what happened to my report: do run this little script on your own machine: the html eats all spaces that have been generated automagically to align the columns. This results in an apparently not fromatted text. Do try it out though, and you'll see the power of the format and write combination.)
[This message has been edited by gvh (edited 04-28-2000).]