Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Report Formatting

by octopusgrabbus (Acolyte)
on Aug 05, 2013 at 15:58 UTC ( [id://1047925]=perlquestion: print w/replies, xml ) Need Help??

octopusgrabbus has asked for the wisdom of the Perl Monks concerning the following question:

I am migrating several Informix 4GL programs to Perl. Perl has a rich library of packages for everything, and I am wondering which packages to look at that would allow me to format data, so that output columns can be fixed?

I am only interested in producing ascii output, and to keep the report values neat. Imagine if you had to read account numbers, names, addresses, water meter data, and so on, you might want output that was neatly ordered. That is what I am after.

I am also going to produce .csv output, but this question is about a report that can be printed easily and output to PDF.

I am not concerned about the grouping/sorting that Informix provides, because Perl's DBI provides me a very strong workaround.

Any suggestions would be appreciated.

Thanks.

Replies are listed 'Best First'.
Re: Report Formatting
by toolic (Bishop) on Aug 05, 2013 at 16:55 UTC
Re: Report Formatting
by stefbv (Curate) on Aug 05, 2013 at 17:10 UTC
Re: Report Formatting
by Skeeve (Parson) on Aug 05, 2013 at 18:36 UTC

    What about "good old" write and FORMAT?


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Re: Report Formatting
by Laurent_R (Canon) on Aug 05, 2013 at 18:48 UTC

    Take a look at the format group of functions in core Perl. I personally have never have had any real use for it, but it seems it might just fit what you want to do.

Re: Report Formatting
by Anonymous Monk on Aug 07, 2013 at 18:21 UTC

    Some other options to what has already been mentioned:

    1. (s)printf. Old-school, but it's simple and it works.
    2. Using a markup language (HTML, PoD, TeX, troff, etc) and feeding it to the appropriate formatting engine. Lots of helper packages in this space (Template::Toolkit, pod2*, etc)
    3. creating PDF output directly (PDF::Create, PDF::Report, PDF::Report::Table).

      As it turns out, I've gone to flat files and sprintf for the largest report.

      I'm using

      Text::Table
      for a report that does not require a large number of columns. It's quite convenient.

      not as wide a report, but I could not get tight enough control over 14 columns for the major report, which is why I decided to use sprintf.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1047925]
Approved by Loops
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-20 01:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found