I want to read a file named sports.txt and generate a report in a file named blank.txt with proper formatting. I've written this code to perform the task but the format in which I want the report I am unable to get that

CODE : format DATA2= ------------------------------------------------------------ @<<<<<<<<<<< @<<<<<<<<< @######### @######## $name $format $matches $runs ------------------------------------------------------------ . format DATA2_TOP= ============================================================ Name Format of match matches played runs scored page@<< $% ============================================================ . #select(DATA2); open(DATA,"<C:/Perl/perl_tests/sports.txt"); @array=<DATA>; close(DATA); open(DATA2,">>c:/perl/perl_tests/blank.txt"); foreach(@array) { chop; ($name,$format,$matches,$runs)=(split(/!/)); write(DATA2); } open(DATA2,"<c:/perl/perl_tests/blank.txt"); while(<DATA2>) { print("$_\n"); } close(DATA2);
FORMATTED REPORT WHICH I AM GETTING IS : ============================================================ Name Format of match matches played runs scored page 1 ============================================================ ------------------------------------------------------------ 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 134 ------------------------------------------------------------
FORMATTED REPORT WHICH I WANT IS : ============================================================ Name Format of match matches played runs scored page 1 ============================================================ ------------------------------------------------------------ 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 134 ------------------------------------------------------------
sports.txt file is : 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

Any Suggestions about how to proceed with this issue?


In reply to 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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.