Perl code can be remarkably compact if your requirements are loose (as they appear to be).
#!/usr/bin/perl
use strict;
my $important;
while ( ( $_ = <DATA> ) !~ /^\-{10,}$/ )
{ $important = $1 if /^Important Text: (\d+)$/i; }
while ( <DATA> )
{ print join ( ",", $important, split ( /\s+/ ) ) . "\n"; }
__DATA__
Date 08/17/11 Report Page 1
Time 12:46
Important Text: 1
Misc Text: All
Misc Text: Sec
** Indicates
APPTEXT
PLINE SCODE PCODE FID SEC unsec fcs
----------------------------------------------------------------------
+---------------------------
TEST TT TT00 TT00.1 NO xxxx TTD
TEST TT TT00 **TT00.2 YES XXXXXX
TEST TT TT00 **TT00.3 YES XXX
TEST TT TT01 TT01.1 NO XXXXXXXXXXX TT
TEST TT **TT02 TT02.1 YES XXXXX
Output:
1,TEST,TT,TT00,TT00.1,NO,xxxx,TTD
1,TEST,TT,TT00,**TT00.2,YES,XXXXXX
1,TEST,TT,TT00,**TT00.3,YES,XXX
1,TEST,TT,TT01,TT01.1,NO,XXXXXXXXXXX,TT
1,TEST,TT,**TT02,TT02.1,YES,XXXXX
-
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.