Hello Everybody
I am facing some problems while processing a file containing a several lines like this :
1 1134177124.U.0 1134177124.+.613 1134177163.+.2234 1134208365.D 1134520916.U.0
I need to arrange it like this:
1 1134177124 U 0
1 1134177124 + 613
1 1134177163 + 2234
1 1134208365 D
1 1134520916 U 0
I am using this piece of code but it doesn't process the file as I want:
#!usr/bin/perl
use warnings;
use strict;
my $iq= 'testtrack.txt';
my $id= 'op.txt';
my $b='';
my $a='';
our($length);
open(INFILE,"$iq");
open(OUTFILE,">$id");
while(<INFILE>)
{
my $line= $_;
my $temp=$line;
chomp($line);
$length = length($line);
my $i=0;
my $j=0;
my $digit_begin;
$digit_begin=0;
while($i <= $length)
{
if($line =~ m/^\d/)
{
$a=substr($line,0,1);
$i++;
$line=substr($temp,$i,$length);
print OUTFILE"$a\n";
$digit_begin = 1;
}
if($line =~ m/^\s/)
{
$i++;
$j=0;
$line=substr($temp,$i,$length);
if($digit_begin != 1)
{
print OUTFILE"\n$a";
}
}
if($line =~ m/^\d{10}/)
{
$b=substr($temp,$i,10);
print OUTFILE" $b";
$i=$i+10;
$line=substr($temp,$i,$length);
$j=0;
}
if($line =~ m/^\./)
{
$i++;
$j=$j+1;
$line=substr($temp,$i,$length);
}
if($line =~ m/[+DU]/)
{
$b=substr($temp,$i,1);
print OUTFILE"\t $b";
$i++;
$line=substr($temp,$i,$length);
}
}
}
close(INFILE);
close(OUTFILE);
exit;
Can somebody help me with this . Thanks a lot.
cheers
Aj