D
Deepu
Hi All,
I have a file like: (test1)
SA blk: 2 pg: 4 col: 5 time: 4
SB blk: 4 pg: 4 col: 6 time: 4
SC blk: 5 pg: 3 col: 3 time: 2
SD blk: 1 pg: 2 col: 8 time: 9
SE blk: 8 pg: 0 col: 3 time: 10
SF blk: 2 pg: 1 col: 6 time: 11
SG blk: 5 pg: 9 col: 0 time: 45
I am trying to generate the output:
SA - SB - SC
SB - SC - SD
SC - SD - SE
SD - SE - SF
SE - SF - SG
But i am getting:
SA - SB - SC
SB - SC - SD
SC - SD - SE
SD - SE - SF
Here i am missing out the last SE - SF - SG.
The array in the code below (@seen) has SE - SF and SF - SG. I need to
combine these and delete SF to get SE - SF - SG. Can somebody please
give me some ideas on it.
The code i am using is:
#!/usr/bin/perl
open (FILE, "test1") || die;
while (<FILE>) {
chomp;
push (@array, $_);
#print "@array\n";
}
$elements = $#array;
for my $i (0 .. $elements) {
my $line = $array[$i];
#print $line;
if (($line !~
/^\s*(\S+)\t+blk:\s+(\S+)\s+pg:\s+(\S+)\s+col:\s+(\S+)\s+time:\s+(\S+)/)){
print "Bad line:$line\n";
}
if (@prev) {
my $stKey = "$prev[1]-$1";
#print "######$stKey######\n";
threeState($stKey);
}
@prev = ($line, $1);
}
close (FILE);
my @seen =();
sub threeState($)
{
my $state = $_[0];
print "$_[0]\n";
if (@seen < 2) {
push (@seen, $state);
print "#!#!#!#!#!!#!#!@seen#!#!#!#!#!#!\n";
} else {
my $key=join '-',@seen;
@test = split(/-/,$key);
splice (@test,1,1);
my $key=join '-',@test;
print
"########################################################$key\n";
if ($covValidAA{"$key"}) {
$covSTCntAA{"$key"}++;
#print "$stKey $covSTCntAA{$stKey}\n";
} else {
if (~$covValidAA{"$key"}) {
$covSTCntAA{"$key"}--;
}
}
shift @seen;
push (@seen,$state);
print "@seen\n";
}
}
Thanks for your time.
I have a file like: (test1)
SA blk: 2 pg: 4 col: 5 time: 4
SB blk: 4 pg: 4 col: 6 time: 4
SC blk: 5 pg: 3 col: 3 time: 2
SD blk: 1 pg: 2 col: 8 time: 9
SE blk: 8 pg: 0 col: 3 time: 10
SF blk: 2 pg: 1 col: 6 time: 11
SG blk: 5 pg: 9 col: 0 time: 45
I am trying to generate the output:
SA - SB - SC
SB - SC - SD
SC - SD - SE
SD - SE - SF
SE - SF - SG
But i am getting:
SA - SB - SC
SB - SC - SD
SC - SD - SE
SD - SE - SF
Here i am missing out the last SE - SF - SG.
The array in the code below (@seen) has SE - SF and SF - SG. I need to
combine these and delete SF to get SE - SF - SG. Can somebody please
give me some ideas on it.
The code i am using is:
#!/usr/bin/perl
open (FILE, "test1") || die;
while (<FILE>) {
chomp;
push (@array, $_);
#print "@array\n";
}
$elements = $#array;
for my $i (0 .. $elements) {
my $line = $array[$i];
#print $line;
if (($line !~
/^\s*(\S+)\t+blk:\s+(\S+)\s+pg:\s+(\S+)\s+col:\s+(\S+)\s+time:\s+(\S+)/)){
print "Bad line:$line\n";
}
if (@prev) {
my $stKey = "$prev[1]-$1";
#print "######$stKey######\n";
threeState($stKey);
}
@prev = ($line, $1);
}
close (FILE);
my @seen =();
sub threeState($)
{
my $state = $_[0];
print "$_[0]\n";
if (@seen < 2) {
push (@seen, $state);
print "#!#!#!#!#!!#!#!@seen#!#!#!#!#!#!\n";
} else {
my $key=join '-',@seen;
@test = split(/-/,$key);
splice (@test,1,1);
my $key=join '-',@test;
"########################################################$key\n";
if ($covValidAA{"$key"}) {
$covSTCntAA{"$key"}++;
#print "$stKey $covSTCntAA{$stKey}\n";
} else {
if (~$covValidAA{"$key"}) {
$covSTCntAA{"$key"}--;
}
}
shift @seen;
push (@seen,$state);
print "@seen\n";
}
}
Thanks for your time.