Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

For your report, printf is plenty sufficient (See sprintf for the formatting codes). For example:

use strict; use warnings; my $APPROX_LINES_PER_PAGE = 4; my $sep = ('-'x60)."\n"; my $header = <<HEADER; ============================================================ Name Format of match matches played runs scored page %d ============================================================ HEADER my $format = "%-18s %-8s %-15s %s\n"; my $cur_pers = ''; my $page = 0; my $lines = 0; while (<DATA>){ chomp; my @elements = split /!/,$_; if (0 == $page or $lines >= $APPROX_LINES_PER_PAGE) { print $sep if $page; print "\n";# or do whatever you want to do between pages $page++; $lines = 0; $cur_pers = ''; printf $header, $page; } # check if person change if ($cur_pers and $cur_pers ne $elements[0]) { print $sep; $lines++; } $cur_pers = $elements[0]; printf $format, @elements; $lines++; } print $sep; print "\n"; __DATA__ sachin tendulkar!ODI!434!12000 sachin tendulkar!Test!246!10900 sachin tendulkar!T20!189!5000 sourav ganguly!ODI!334!8000 sourav ganguly!Test!235!5000 sourav ganguly!T20!124!1800 rahul dravid!ODI!387!9000 rahul dravid!Test!212!5980 rahul dravid!T20!43!1345

I've added some sample pagination - I'm not sure what you had in mind there, but you should be able to extend it to what you wanted.

Good Day,
    Dean


In reply to Re^3: Report generation through formats by duelafn
in thread Report generation through formats by ankit.tayal560

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-25 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found