Will you offer some help? Thx MUCH!!!!! I am trying to get to this, for every 5 lines of data in the raw file (which is one record), I need to output 6 lines into the output file. Every record should have 'F' be the last line, and 'A' should be the start of the next record. Line F needs to be created for each record and should contain the text 'acctnum=' and then use the first two pieces of data in line A to create the acctnum.

A 5##### 8 Z Axxxx xxxx, ANN 19793.43 02/02/2012 06/08/ +2012 32989.05 B 03###### S JOxxx xxxx, ADxxx .00 xx/xx/xxxx + 0 C 0 7 14## D xxxx ST #101 .00 02/08/2012 06/ +15/2012 NOV D 0 U MILWAUKEE, WI ##### 32989.05 02/08/2012 + 3 E 3##### MILWAUKEE WI .00 53214 + 12 F acctnum=508####8 A 50#### 8 Z ALLEN ,Nxxxxx 75.00 05/27/2012 06/05 +/2012 1845.00 B 037###### E Nxxxx ALLEN .00 09/xx/xxx 06/05/ +2012 MYT####### C 734####### S 15659 XXXX xxxxx .00 06/06/2012 06/1 +4/2012 MYT9##### NOV D 0 C TAYLOR,MI ##### 1845.00 05/27/2012 + 3 3 E 37##### S TAYLOR MI .00 48180 + 3 12 F acctnum=50##### A 50##### 9 Z Axxxx xxxxxx ,SUSETH 75.00 05/05/2012 05/15/2 +012 2045.00 B 0000000000 E SUSE xxxxxxx RIxxx .00 03/18/xxxx 05/15 +/2012 AJT9###### C 313###### 440 xxx xxxx .00 05/16/2012 06/1 +5/2012 AJT9#2###### NOV D 0 C LINCOLN PARK,XX xx### 2045.00 05/05/2012 + 1 3 E 0 S LINCOLN PARK XX .00 481 +46 1 12 F acctnum=50#####

From this: $ cat tstin

0 S LINCOLN PARK MI .00 4 +8146 1 12

My Perl code....been trying and trying....this is like my 5th mod.

use strict; use warnings; my $vers = q|1.5|; my $letter = 'A'; #my $file = qq(/var/adm/scripts/20121106_C1SA_174204.tmp); my $file = qq(/var/adm/scripts/tstin); my ($acctnum,@acctnum); open (my $f, "+<", $file) or die $!; while (my $ln = (<$f>)) { #next if ($. == 1..88); next if $ln !~ /\s\s\s\s\d+.*/; next if $ln =~ /\A\w+|\cM\s\d+\.\d+.*/; substr($ln, 1,2) = ""; substr($ln, 0,1) = $letter++; if ( $. % 5 == 1 ) { ###-- every 5th line --### if ( substr($ln, 10, 4) =~ /\s+/ ) { substr($ln, 10, 4, ""); $acctnum = substr($ln, 2, 10); push @acctnum, "F acctnum=$acctnum"; } } ###-- 79/80 are the 2 spaces not needed --### if ( length(substr($ln, 79, 2)) > 1 || substr($ln, 79, 2) =~ /\s*/ + ) { substr($ln, 79, 2, ""); print $ln; } else { next; } }

In reply to raw data formatting by teamassociated

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.