ankit.tayal560 has asked for the wisdom of the Perl Monks concerning the following question:
SCRIPT TO GENERATE REPORT : use warnings; format DATA2= ------------------------------------------------------------ @<<<<<<<<<<<<< @<<<<<<<<< @######### @######## $name $format $matches $runs ------------------------------------------------------------ . format DATA2_TOP= Records/Data of the trio ============================================================ Name Format of match matches played runs scored ============================================================ . 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); }
My sports.txt file is as follows:
sports.txt file : 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
The formatted report which I am getting in blank.txt is the final report I want but here in this script the heading of the report i.e. "records/data of the trio" is directly given. how can I pass a variable in place of that title.?Any Help is appreciated!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to pass a Format Heading from a variable?
by GrandFather (Saint) on Oct 20, 2016 at 05:33 UTC | |
|
Re: How to pass a Format Heading from a variable?
by GrandFather (Saint) on Oct 20, 2016 at 05:56 UTC | |
|
Re: How to pass a Format Heading from a variable?
by kcott (Archbishop) on Oct 20, 2016 at 08:03 UTC |