r0adawg 0 Newbie Poster

Hello,

I'm new with perl, I've been able to read and write from file #1 to file #2. file #1 currently is about 60meg of text...

what I would like to do is to read up to 2 char from a constant position and then use that data in a loop to add missing data to the end of the current line x times

the second and third line the # of char will be 4 and at a constant position.

the 2nd and 3rd lines show the number of samples taken... I'm needing to add zero data so that the total samples = 2000, so adding the remainder of what is missing. data could be 0, for each missing sample. again in a loop.

any and all help and/or instruction welcome.

#!c:\perl\bin\perl -w
use strict;
use warnings;

open(INP, '<c:\video\original.txt') or die("Can not open file original.txt for reading\n");
open(OUTP, '>c:\video\fun.txt') or die("Cannot open file fun3.txt for writing\n");

my ($skip) = 14;		#define number of lines to skip
1 while $skip-- && <INP>;	# skip n lines

my ($linecount);

$linecount = 0;
while ( <INP> )
      {
        chomp();
        s/:  /:, /g;
	s/ngth=/ngth=,/g;
        s/ S/ ,S/g;
        s/ G/ ,G/g;
        s/ H/ ,H/g;
        s/  \(LC1/  ,(LC1/g;
        print OUTP "$_";
        $linecount++;

        if ($linecount == 1 )
                {
                print OUTP ";";
                }
        if ($linecount == 2 )
        	{
                print OUTP ";";
                }
        if ($linecount == 3)
        	{
        	print OUTP "\n";
                $linecount = 0;
        	}
      }

close 'INP';
close 'OUTP';
print "DONE!!!\n";

__DATA__
x:  xxxxxxxxxxx   xxxxxxx,  2 xxxxx                  0.0

                  xxxx xx Samples=1278, xxxxxx=500         0,0,0,0
                  xxxx xx Samples=578, xxxxxx=500         0,0,0,0