CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: Throw Down The Gauntlet:
Need Report scripts

 



Mcampb9713
Deleted

Apr 28, 2000, 7:18 AM

Post #1 of 2 (2504 views)
Need Report scripts Can't Post

I need a program that prints a reports as I parse data from a flat file... Either the report from the clean prsed file or as each record is done... The report looks like:
Header

Date Time of report

Item1 Item2 Item3 Item4 Item5 Item6
_____ _____ _____ _____ _____ ____

(details)
.... .... .... .... .... ....
.... .... .... .... .... ....


Footer

This report can be save to disk and in MSWord, HTML or Text format.

Thanks


gvh
Deleted

Apr 28, 2000, 2:56 PM

Post #2 of 2 (2504 views)
Re: Need Report scripts [In reply to] Can't Post

The standard Perl repot formatting functionality serves very well for text format reports. As an example a little script that shows how easy this is:


Code
#! 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

@&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;
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:


Code
 
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).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives